The sorting has broken when using the script field (Script Runner)

The sorting has broken when value in the script field is changed without editing a JIRA issue.

  • I created a script field and enable for Story type.
  • The script that I created, it is used for getting the number of Open Bugs that are being linked to that Story. 

import com.atlassian.jira.component.ComponentAccessor

def closeNames = ["Closed", "Resolved"]
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def issueLinks = issueLinkManager.getInwardLinks(

def subElements = issueLinks.findAll {
it.getIssueLinkType().getName() == "Bug to Story"
}.findAll {
!( in closeNames)
}.findAll { == "Bug"

return subElements.size() as Double

  • The result on the script field returns properly. 
    For example: I have 2 Stories, SPT-6 and SPT-23
         SPT-6 has 2 opened bugs (SPT-20 and SPT-53) -> The script field shows "2"
         SPT-23 has 3 opened bugs (SPT-21, SPT-57, SPT-74) -> The script field shows "3"
    The result shows correctly, including sorting by using ORDER BY ASC or DESC

  • When I close some bugs, e.g. SPT-21 and SPT-57, the script field still calculates correctly, it show "1", instead of "3" on Story SPT-23. But the sorting has broken, it's not updated until I edit any field in SPT-23 or re-indexing JIRA.  

Please help investigate, is this a bug or is there any solution to fix this problem?

Thank you in advance. Any question on my information above, please let me know.




3 answers

Hi Orawan,

What Searcher and Template you use for your scripted field ?

0 votes

This is not technically correct in the background, but an easy way to think about scripted fields is that "they store their data in the index, so they only get updated when an issue is indexed".  The changes you are making to issues at the other end of the links do not trigger any indexing on the Story.

Sadly, for links, there's no way to fix this that I know of - changes to links don't fire events that could be caught and checked for changes that might need an indexing run against an issue.

Hi Nic,

Thank you for this information T_T 

May I ask you, is it possible to have improvement regarding this case in new version of JIRA or ScriptRunner plug-in?

An improvement here would need JIRA to support the firing of events for changes on links.  I'm not sure ScriptRunner could be made to handle anything without support from JIRA.

Hi Thanos,

I use Search Template "Number range searcher". 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Monday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

499 views 0 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