Greetings
We currently have a scripted field which gives a percentage of stories estimated to an epic.
This has worked well for us, however we now want to only summarize stories when the story points field is > 0, where the resolution is empty, or set to the values of "Fixed" or "Done". All other stories, we do not wish to summarize.
Below is our current code.
Any recommendations on how to obtain the resolution value, and add the above criteria?
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 totalStoriesEstimated = 0
double totalStoriesUnestimated = 0
double totalStories = 0
double percentEstimated = 0
double SP = 0
def storyestimated = false
customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10073");
if (issue.getIssueTypeId() != "17") {
return null
}
issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->
if (issueLink.issueLinkType.name == "Epic-Story Link" ) {
SP = (double)(issueLink.destinationObject.getCustomFieldValue(customField) ?: 0)
totalStories++;
if (SP > 0) {
totalStoriesEstimated++;
}
}
percentEstimated = ((totalStoriesEstimated ) / totalStories) * 100;
if (percentEstimated <= 0) {
percentEstimated = 0}
}
return percentEstimated
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 totalStoriesEstimated = 0
double totalStoriesUnestimated = 0
double totalStories = 0
double percentEstimated = 0
double SP = 0
def storyestimated = false
customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10073");
if (issue.getIssueTypeId() != "17") {
return null
}
issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->
if (issueLink.issueLinkType.name == "Epic-Story Link" ) {
SP = (double)(issueLink.destinationObject.getCustomFieldValue(customField) ?: 0)
def resolution = issueLink.destinationObject.getResolution()
if (resolution == null || resolution.name == "Done" || resolution.name == "Fixed") {
totalStories++;
if (SP > 0 ) {
totalStoriesEstimated++;
}
}
}
percentEstimated = ((totalStoriesEstimated ) / totalStories) * 100;
if (percentEstimated <= 0) {
percentEstimated = 0}
}
return percentEstimated
Really appreciate your assistance @Alexey Matveev! Will give this a try and let you know if we have any questions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.