I have a custom scripted field named "Epic Σ Original Estimate (Hours)" which holds a numeric value.
I have another custom scripted field named "Feature Σ Original Estimate (Hours)" which I need to sum up the total held in "Epic Σ Original Estimate (Hours)" for any related Epics.
In my groovy script I'm making use of getCustomFieldValue but even though I can see I have a value in "Epic Σ Original Estimate (Hours)" it's not being pulled through.
Am I making a beginners error in trying to reference the value returned by a custom scripted field from another custom scripted field?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLinkType
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.issue.CustomFieldManager
def cfManager = ComponentAccessor.getCustomFieldManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def customField = customFieldManager.getCustomFieldObjectByName("Epic Σ Original Estimate (Hours)");
long originalEstimateTotal = 0
// Perform only for Epics
if (issue.getIssueType().name == "Epic") {
IssueLinkTypeManager issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)
IssueLinkManager issueLinkManager = ComponentAccessor.issueLinkManager
// Get all the top level issues in the Epic.
Collection<IssueLinkType> epicToStoryLinkTypes = issueLinkTypeManager.getIssueLinkTypesByName('Roadmap Item Relationship')
if (epicToStoryLinkTypes) {
def linkedStories = issueLinkManager.getOutwardLinks(issue.id).findAll{it.linkTypeId == epicToStoryLinkTypes[0].id}*.destinationObject
if (linkedStories.size() > 0) {
// Process each issue linked to the Epic
for (int index = 0; index < linkedStories.size(); index++) {
Issue currentIssue = linkedStories[index]
if (currentIssue) {
log.warn("value=" + currentIssue.getCustomFieldValue(customField))
log.warn("key=" + currentIssue.getKey() )
originalEstimateTotal = originalEstimateTotal += currentIssue.getCustomFieldValue(customField) ?: 0
}
}
}
}
}
return originalEstimateTotal