I'm currently working on burnup chart to see the count of subtasks of each story.
So, I'm thinking about automate the count of subtasks each time a subtasks created, then put it on Custom Field of the parent, let's say `Number of Tasks`.
I've been looking and didn't found any beginner advise how to do this. Any help will be appreciated
Something like this should work in a number Script Field to count the number of subtasks for each issue.
if (issue.getIssueType().name != "Sub-task") { // only calculate this for non-subtask issues
def subTaskSum = 0
issue.getSubTaskObjects()?.each { subtask -> // go through all subTask issues
subTaskSum += 1
}
return subTaskSum
}
Regards,
Josh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Joshua Yamdogo @ Adaptavist This is great!
Is it possible to filter this to only count specifically depending on subtask issue type?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm getting this error message when I try this snippet:
An error occurred whilst running the scripted field.
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.getIssueType() is applicable for argument types: () values: [] at TestScriptedFieldExecution1_groovyProxy.run(Unknown Source) Caused by: groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.getIssueType() is applicable for argument types: () values: [] at Script1.run(Script1.groovy:1) at Script1$run.call(Unknown Source) at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:39) at com.adaptavist.sr.cloud.events.ScriptedFieldExecution.run(ScriptedFieldExecution.groovy:30) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at TestScriptedFieldExecution1_groovyProxy.run(Unknown Source) at com.adaptavist.sr.cloud.MainHandler.executeScript(MainHandler.groovy:402) at com.adaptavist.sr.cloud.MainHandler.processInput(MainHandler.groovy:347) at com.adaptavist.sr.cloud.MainHandler.access$0(MainHandler.groovy) at com.adaptavist.sr.cloud.MainHandler$_handleRequest_closure1.doCall(MainHandler.groovy:167) at com.adaptavist.sr.cloud.MainHandler$_handleRequest_closure1.call(MainHandler.groovy)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Joshua Yamdogo @ Adaptavist ,
I have a requirement . Add Sub-Task Count (Numeric) field to be auto-updated based on related sub-tasks (child) with a Status != Closed.
Your code is working as expected, but its displaying all tickets, but i don't want closed/done tickets display on the main ticket. Could you please suggest ?
if (issue.getIssueType().name != "Sub-task") { // only calculate this for non-subtask issues
def subTaskSum = 0
issue.getSubTaskObjects()?.each { subtask -> // go through all subTask issues
subTaskSum += 1
}
return subTaskSum
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You have to use the Scriptrunner plugin to create a plugin which runs on issue created event.
The script should be able to fetch the links using the issueLinkManager. The getOutwardLinks() method will fetch you all the child links for that specific issue.
-Praveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
Thanks for the reply. And yes, I do eventually use Script Runner. What I've been doing is creating new custom field that automatically fetch the child / subtasks of current issue and you can further filter is for resolved only.
But I didn't use the issueLinkManager, can you give me some example so that this might be one of the alternative, hopefully more efficient, answer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.