Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Summing up a field in a subtask and posting it on the parent issue field

Jon
Contributor
February 4, 2019

hi, 

our subtasks contain a field called quantity. each issue contains 10-40 subtasks. I was wondering if jira can sum up the total of all of these subtasks and populate that total in the field we have on the parent called total quantity. 

 

is anything like this possible? 

1 answer

1 vote
Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 6, 2019

Hello Jon,

You can perform this sum using a Scripted field provided by ScriptRunner Plugin. This would be the code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField

//return number subtasks
issue.getSubTaskObjects().size()

CustomField total = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Total")
double totalSum = 0;
for(Issue subtask: issue.getSubTaskObjects()){
    if(subtask.getCustomFieldValue(total) != null)
        totalSum += subtask.getCustomFieldValue(total)
}

return totalSum

For more reference, you can check the answers below:

Sum of custom field values from subtasks in parent issue custom groovy field

Sum of values from subtasks using JIRA Calculated Number Field

Let me know if this information helps.

Jon
Contributor
February 6, 2019

Interesting, let me check it out. Will it also work for issues that are linked to epics? 

Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 19, 2019

Hello Jon,

For sum-up values of stories to a linked Epic, you can use the free plugin Epic Sum up - Light.

Let me know if it helps.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events