How to aggregate number/calculated number fields of all Issues within an Epic?

Jamie Hillyar September 8, 2016

I've seen a number of different questions similar to this, but have had no luck in combining the various solutions into one that fits for me!

We have Issues within Epics (not storys), and capture costings/aggregated costings within the Issue. I'm trying to pull the aggregated costings for all Issues in an Epic, to give a total "cost" for the Epic. This is quite new to me so any help in triage would be greatly appreciated. The Epic is currently showing the field but not pulling the figures across the link.

This is what I've got:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor;

def componentManager = ComponentManager.getInstance()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def cfManager = ComponentAccessor.getCustomFieldManager()

customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11078");

def totalSP = 0
issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->
if (issueLink.issueLinkType.name == "Epic-Story Link") {
def linkedIssue = issueLink.destinationObject
def SP = linkedIssue.getCustomFieldValue(customField) ?: 0
totalSP += SP
}
}
return totalSP

 

Many thanks,

Jamie

3 answers

0 votes
Petar Petrov (Appfire)
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.
September 8, 2016

There doesn't seem to be anything obviously wrong - I would put the script in the Script Runner console (not sure if it has it on cloud?) and try it with a given issue id - check what is returned for the custom field value of each linked issue.

0 votes
Jamie Hillyar September 8, 2016

Cloud JIRA v6.3.11. Using Script Runner

0 votes
Petar Petrov (Appfire)
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.
September 8, 2016

Are you using server or cloud JIRA, which version? Where do you put this groovy script?

Suggest an answer

Log in or Sign up to answer