Scripted field to sum story points of issues linked to an epic in closed status

I am trying to create a scripted field that will sum the story points of issues linked to an epic that are in closed status.

JIRA version: 7.1.6 server

Scriptrunner version: 4.3.12

Searcher: Number searcher

Template: Number field

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()
double totalSP = 0
customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12110");
enableCache = {-> false}

issueLinkManager.getOutwardLinks( {issueLink ->
if (( == "Epic-Story Link" ) && (issue.getStatus() == "Closed")){
double SP = (double)(issueLink.destinationObject.getCustomFieldValue(customField) ?: 0)
totalSP = SP + totalSP;
return totalSP

It is returning a result of 0. 

I am new to scripted fields and need help troubleshooting. Thanks!

1 answer

Hi Colleen,

I think what you miss (apart form the first import that does not exist) is the 

issue.getStatus() == "Closed"

it should be 

issue.getStatus().name == "Done" 
// or if you need the category and not just the name of the status
issue.getStatus() == "Closed"

apart from that your script seems fine. And one more thing, I suppose the customfield_12110 is the Story Points, wouldn't be more clear If it was 

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Story Points")

regards, Thanos

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,305 views 14 20
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
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