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

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

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

Cloud JIRA v6.3.11. Using Script Runner

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.

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

930 views 5 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot