Hi, I know that is a hot subject among Jira, have more than 100+ threads about, suggestions with more than 3k total votes, but some reason still not solved inside Jira or some reason I don't know (the suggestion with 1.6K votes is from 2013!!!!).
As I don't like to give him im searching for the way to roll up the summing of the story points sub-tasks have into his parent issue, just to be clear about what I'm talking about is this:
Issues have sub-tasks under it; you can add story points field to sub-tasks
If you have an issue called "Story X" and under it, there are two sub-tasks with 6 story points each, then the logic is that the story will contain 12 story points, or at the minimum give the user the possibility to choose if this is how he wants to calculate story points.
So I have tried plugins and many customizations through Jira dashboard and didn't succeed, but I have found this script example under Scriptrunner documentation that rolls up time estimation to parent issue, with just simple 30 lines of listener code:
So my question is if someone knows how to tweak this code (because it looks pretty simple for someone who knows how to code JQL) to roll up story points to the parent issue?
Of course, if you have other solution or clear answer (not because "this is how it works" thing that I have saw from some "coaches" out there, because good products solve user needs, and not hold him back), I would like to hear that.
Hi! thank you very much, have you seen that is on the cloud? your article is on a server and not cloud, as I don't find "scripted field" under the add custom field, any idea?
Ah, I missed the cloud detail; I think modifying the script that Adaptavist provided is the way to go.
I'd start with modifying the line that has the number 2 next to it.
.queryString("fields", "parent,timeestimate")
should get changed to
.queryString("fields", "parent,customfield_xxxxx")
where the xxxxx is the id of the story point field.
Something like that. You also need to create the "Summed Subtask Estimate" field.
This is not tested so I may be wrong here.
So the steps you suggest are:
1. Create custom field
2. create a listener in Scriptrunner with the same code
3. change the strings mentioned above, according to the custome field?
Hi Liran,
I can confirm that you can modify the Store Subtask Estimates in Parent issue on Issue events example in the documentation to sum up story points.
I have included a link here to a modified version of this example that you can use to do this.
Please note that when configuring this example as a Script Listener you will need to:
If this answer has solved your issue can you please accept it in order to mark this answer as correct for users who are searching for a similar issue.
Regards,
Kristian
Thank you so much, works like a charm!
I even disabled other plugin that does part of that, I'm gonna spread the word!
Hi Liran,
Thank you for confirming that issue has now been resolved.
Could you please mark this answer as accepted so that other users searching for the same question know this is a correct answer.
Thanks
Kristian
I think because this is a discussion and not a question I can't mark it as correct answer but I edit the title and wrote SOLVED.
Thank you Liran.
This is fine and will show people searching for a similar question that the answer is correct.
Regards,
Kristian
Hi Kristian, have any quick idea about the next problem:
The script works well, every time I add story points it updates the main parent story, the only problem that if I put sub-task in done, it does not update the story points (eliminate the summing of story points of done sub-task.
Also, it does not show how many story points made so far regarding sub-tasks, this could be much more complex as i understand, but at least minus the subtasks story when they have done, it should be pretty simple add in the code I guess.
Thank you again!
Hi Liran,
Thank you for your response.
The script is designed to just sum up the story points from all sub tasks and does not check what status a sub task is in.
You would either need to update the script to check the status of each sub task and not sum up its value if it is in the Done status or you would need to add a post function onto the sub task workflow to clear the value of the story points field when the sub task is put into the Done status.
Atlassian provide the Clear Field Value post function out of the box which you could use to clear the story points on the sub task when it go's into the Sub Task status.
Regards,
Kristian
Hi, Kristian
I tried to use your script (https://bitbucket.org/snippets/Adaptavist/aeGy6K), but it looks like it is outdated.
I created a custom listener, added your script, modified values of fields. But script is not working.
Here is what I made for current moment.
/*
* This listener must be set to fire on the issue updated event and the field specified
* to store the value must be on the issue screens
* "All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner
* license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed or
* amended and must be included in any circumstances where the code snippet is shared by You or a third party."
*/
if (!issue.issueType.subTask) {
return
}
// Retrieve all the subtasks of this issue's parent
def parentKey = issue.getParentObject().getKey()
def allSubtasks = get("/rest/api/2/search")
.queryString("jql", "parent=${parentKey}")
.queryString("fields", "parent,customfield_10106") // Update this line with the ID of the story points field for your instance.
.asObject(Map)
.body
.issues as List<Map>
logger.info("Total subtasks for ${parentKey}: ${allSubtasks.size()}")
// Sum the estimates
def estimate = allSubtasks.collect { Map subtask ->
subtask.fields.customfield_10106 ?: 0 // Update this line with the ID of the story points field for your instance.
}.sum()
logger.info("Summed estimate: ${estimate}")
// Get the field ids
def fields = get('/rest/api/2/field')
.asObject(List)
.body as List<Map>
// Note - The custom field specified here must be a number field as it returns a number type
def summedEstimateField = fields.find { it.name == "Story Points" }.id // Update this Line with the name of your Custom Number field that will store the value on your parent issue.
logger.info("Custom field ID to update: ${summedEstimateField}")
// Now update the parent issue
def result = put("/rest/api/2/issue/${parentKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
(summedEstimateField): estimate
]
])
.asString()
// check that updating the parent issue worked
assert result.status >= 200 && result.status < 300
Can you help with updating it?
Current error is:
2021-01-18 13:51:02,415 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2021-01-18 13:51:02,416 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.get() is applicable for argument types: (String) values: [/rest/api/2/search] Possible solutions: get(java.lang.String), getAt(java.lang.String), grep(), put(java.lang.String, java.lang.Object), grep(java.lang.Object), wait() at Script376.run(Script376.groovy:15)
Hi Udjin,
Can you please confirm if you are using Jira Server or Data Center or Jira Cloud?
The logs above indicate that you are using Jira Server or Data Center and this script will only work on Jira Cloud.
If you need assistance with doing this on Jira Server or Data Center you should raise a new question and tag this as Jira Server or Data Center so that someone else who is familiar with Jira Server or Data Center can advise on this.
Regards,
Kristian
I'm using Jira Server.
Thank you for advice.