Hi
I am trying to create script field that shows a count of the unresolved sub-tasks on an issue.
I can count all of them using the solution found here - but have been unable to work out how to put in the condition to only return unresolved sub-tasks.
I have also tried modifying the issuetype property in this solution (for counting linked issues) but this does not work for me either. I guess thats not the correct way or I'm missing something.
Scriptrunner is sill new to me so would appreciate any assistance anyone can offer.
Regards, Jamie
Hi,
Try this in your scriptedfied:
def subTaskSum = 0
issue.getSubTaskObjects()?.each {
subtask -> subtask.getResolutionObject()!=null?subTaskSum += 1:subTaskSum
}
I didn't try it, but it should work.
Let me know if it did or not.
Hi @Nir Haimov
Thanks for the reply.
Unfortunately this did not work as the script field box complains this is incorrect "subtask.getResolutionObject()" and to use "issue.getResolution()" instead - which also doesn't work.
I am running Jira 7.13 and Scriptrunner 5.4.43.
Regards, Jamie
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Both "subtask.getResolutionObject()" and "issue.getResolution()" will work.
The error you get is just a suggestion, it's a warning.
Any way, i tested and it works, all you need is just to add in the end of the script this line:
return subTaskSum
So your final code is:
def subTaskSum = 0
issue.getSubTaskObjects()?.each {
subtask -> subtask.getResolution()!=null?subTaskSum += 1:subTaskSum
}
return subTaskSum
Tested in Jira 7.12.2 and Scriptrunner 5.4.40
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Nir Haimov
This works, thank you.
I modified the != to == to get the value I was after was I wanted unresolved subtasks but good to know I can also use != if the requirements change.
Regards, Jamie
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your script. Its helped me in my requirement.
The requirement is,
"Add Sub-Task Count (Numeric) field to be auto-updated based on related sub-tasks (child) with a Status != Closed. "
def subTaskSum = 0
issue.getSubTaskObjects()?.each {
subtask -> subtask.getResolution()==null?subTaskSum += 1:subTaskSum
}
return subTaskSum
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.