Hi,
Jira version 7.2.6
Script runner 1.5.4
I have one script listener to "issue updated" event to update the summery based on the custom fields selection. It is working fine but when I am searching in jql search then summary still showing old one. When I open the issue then summary showing fine so I suspected that issue is not indexing after the update hence did the project indexing manually. After the index of project "summary" showing fine.
Can anyone please help me what should I add in my script listener to reindex automatically when there is update on issue.
Here is the code
package com.custom
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.event.issue.IssueEvent
import org.apache.log4j.Category
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
class SetDefaultFields extends AbstractIssueEventListener {
Category log = Category.getInstance(SetDefaultFields.class)
SetDefaultFields () {
log.setLevel(org.apache.log4j.Level.DEBUG)
}
@Override
void issueUpdated(IssueEvent event) {
// Get custom field value
log.debug "Event300: Start UpdateIssue.groovy"
MutableIssue issue = event.issue as MutableIssue
def cfVal
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def IssueManager issueManager = ComponentAccessor.issueManager
if( issue.getIssueType().getName().equals("Application")){ //changed to this after migration to 7.x
def cf1 = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Division")
def cfDiv = issue.getCustomFieldValue(cf1)
def cf2 = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Name / Sub Type")
Map cfList = issue.getCustomFieldValue(cf2) as Map
if (cfList) {
String first = cfList.get(null)
String second = cfList.get("1")
if (second == null ){
second = "All"
}
// log.debug("First - second: $first - $second")
issue.summary = first + " - " + second + " - " + cfDiv
}
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH ,false)
Thanks
Om.