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(issue.id)?.each {issueLink ->
if ((issueLink.issueLinkType.name == "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!