Hello!
I created a scripted field "Done Story Points" that should display the sum of values of another field from the linked issues.
It is works in two scenarios:
- for Epics: displays a sum of Story Points from the issues it the Epic, include only those issues that are currently in the "Done" status
- for Features: displays a sum of "Done Story Points" from Epics.
It works OK for the first scenario. But it is don't work as expected for the second. I'm trying to restrict the sum operation only to linked Epics (because Feature can be linked to another Feature with link type "Relates to"), but seems like the operator <if (issueType == "Epic")> does not work, like if the script is unable to get "IssueType" value from current linked issue. And as a result field shows sum of "Done Story Points" both from the Epics and from the related Features.
Please help to understand what I'm doing wrong and how can I get the sum of "Done Story Points" in the Feature ONLY from related Epics, ignoring other related Features?
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()
def spField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10002");
def DoneSpField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_14715");
int totalSP = 0
issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->;
def linkedIssue = issueLink.destinationObject
String issueType = issueLink.destinationObject.getIssueType().toString()
if (issueLink.issueLinkType.name == "Epic-Story Link" ) {
def Basestatus = linkedIssue.getStatus().getName();
if (Basestatus=="Done"){
int spValue = (int) (issueLink.destinationObject.getCustomFieldValue(spField) ?: 0)
totalSP = spValue + totalSP;}
}
if (issueLink.issueLinkType.name == "Relates") {
if (issueType == "Epic"){
int spValue = (int) (issueLink.destinationObject.getCustomFieldValue(DoneSpField) ?: 0)
totalSP = spValue + totalSP;
}
}
}
return totalSP