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

This widget could not be displayed.

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

This widget could not be displayed.

Cloud JIRA v6.3.11. Using Script Runner

This widget could not be displayed.

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 Sign up to answer
Community showcase
Posted 6 hours ago in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26 views 0 1
Join discussion

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