Update: Since Jira seems to sort number values from scripted fields lexically (1, 10, 11, 2...) instead of numerically (1, 2, 3...), I updated the description below to return a string value with a three digit number that is left-padded with zeros.
@Matt Parks thanks to your comment I found a solution to do this using a ScriptRunner scripted field returning a template of type "Text Field (multi-line)".
Here is the script for the field:
import com.atlassian.jira.component.ComponentAccessor
def issueLinkManager = ComponentAccessor.issueLinkManager
if (!issue.isSubTask()) {
return null
}
def subTaskLink = issueLinkManager.getInwardLinks(issue.id).find {
it.issueLinkType.name == "jira_subtask_link"
}
return subTaskLink ? String.format("%03d", subTaskLink.sequence) : null
You do not need to add the field to any screen in order to be able to use it. Just write a JQL query returning the desired sub-tasks and use the scripted field in the ORDER BY clause.
Hope this helps!
I wrote this ScriptRunner script in order to automate the rank of the issues depending on the sequence displayed. Thanks @David Waldhans for his snippet, it was so helpful to make this possible. Disclaimer, this is a slow method, so if you use it, you will reach the ScriptRunner timeout (60 seconds) constantly.