Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Scripted Field to Sum the Story Points of Issues sub-tasks

Jim Gould July 6, 2015

Good Day,

 I would like to create a Scripted field (done) that sums the Story Points for all an issues sub-tasks of a specific type.

Here is what I have which sums all the sub-tasks, not just a specific type. Any help is appreciated:

import com.atlassian.jira.ComponentManager

import com.atlassian.jira.issue.CustomFieldManager

import com.atlassian.jira.component.ComponentAccessor;

 

def componentManager = ComponentManager.getInstance()

def issueLinkManager = componentManager.getIssueLinkManager()

def cfManager = ComponentManager.getInstance().getCustomFieldManager()

double totalSP = 0

 

customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Story Points");

issue.subTaskObjects.findAll

{ subtask ->

    def SP = subtask.getCustomFieldValue(customField) ?: 0

    totalSP += SP

}

return totalSP

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 13, 2015

 

Hi Jim, 

 

I answer this here again so that you can mark this question as answered. The complete history is here.

If you are talking about all subtasks of issue type BUILD you can get them like this

issue.subTaskObjects.findAll{it.statusObject.name == 'BUILD'}.each{ subtask -> 
	def SP = subtask.getCustomFieldValue(customField) ?: 0 totalSP += SP 
}

Take care that the name of the issue type is correctly spelled. wink

Henning

0 votes
Jim Gould July 14, 2015

Thank you for all your help!

TAGS
AUG Leaders

Atlassian Community Events