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 Sign up to answer
Community showcase
Posted Tuesday in Statuspage

How do your teams prepare for really high (planned) traffic days like Cyber Monday?

Hi there! Shannon from Statuspage here.  👋  With Cyber Monday quickly approaching, we're looking to hear from Atlassian customers – specifically from teams who touch incident response li...

57 views 0 5
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