script listner summary updated and not populating in search (jql search) issue



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 () {
    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)




1 answer

1 accepted

0 votes
Accepted answer

Om friend:

If you see your last line:

issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH ,false)

The most important bit being:


You are not dispatching an issue update event. Therefore, your JIRA isn't reindexing, that's why your value in your JQL appears as the old one, because you haven't "updated" the database yet.

If you want your listener to update your values the moment it fires, you need to update it with:


That should reindex your issue but be careful. Since if this gets triggered very often it could considerably slow down your JIRA instance performance considerably.

If this solved your doubt, please upvote and accept my answer, since this will let other users know that this question has been answered.



Hi Dyelamos,

As per your comment, I have one doubt. Reindex happen only modified issue alone right not the entire jira instance indexing right?


That should reindex your issue but be careful. Since if this gets triggered very often it could considerably slow down your JIRA instance performance considerably.





Think about Re indexing as follows:

You have a Bookshelf of 1000 books.

You a bookshelf in which you order them by Author. This is your "Index"

And once awhile someone tells you that one was incorrect.

That means that you need to look at your entire list, find the correct book, change the information in your list, physically take the book out, and move it to the correct place.

Now imagine that it isn't only 1 bookshelf, but as many as the custom and system fields that JIRA has.

Now imagine that it isn't 1000 books, but 2 million JIRA issues.

If you re index 400 times in a row. Your librarian might loose his mind right?

Same principle. Yes, you are technically re indexing 1 issue, but what you are re indexing against is the real problem. If you have a small instance, it won't matter too much. But if you have  a big instance and you are reindexing like a maniac, that will take a huge processing time, and you will notice a performance impact.

I hope this helped you out.

If you have anymore questions I'd be happy to help.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,115 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you