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
Community moderators have prevented the ability to post new answers.
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.
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.