Hi,
Now I have a working scripted field which calculates story points of all issues linked with Epic-Story Link. The sum of Story Points is shown in the Epic issue type. Code below:
import com.atlassian.jira.component.ComponentAccessor; def issueLinkManager = ComponentAccessor.getIssueLinkManager() def totalSP = 0.0 enableCache = {-> false} issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink -> if (issueLink.issueLinkType.name == "Epic-Story Link") { customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Story Points") def SP = issueLink.destinationObject.getCustomFieldValue(customField) as Double ?: 0.0 log.debug("SP value ${SP}") totalSP += SP }} return totalSP as Double
Do you know if there is any possibility to somehow limit the calculation of story points based on issue status? (now story points are calculated from all linked with epic link issues (despite of their status), I want to have a calculation only of issues that are not in Done status).
I was trying to add additional condition like (in bold):
import com.atlassian.jira.component.ComponentAccessor;
def doneNames = ["Done"]
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def totalSP = 0.0
enableCache = {-> false}
issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->
if ((!(issue.statusObject.name in doneNames)) && issueLink.issueLinkType.name == "Epic-Story Link") {
customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Story Points")
def SP = issueLink.destinationObject.getCustomFieldValue(customField) as Double ?: 0.0
log.debug("SP value ${SP}")
totalSP += SP
}}
return totalSP as Double
Unfortunately it does not work, could you pelase advise why?
Thanks,
Paulina
I would write it like this:
import com.atlassian.jira.component.ComponentAccessor def doneNames = ["Done"] def issueLinkManager = ComponentAccessor.getIssueLinkManager() def totalSP = 0.0 enableCache = {-> false} def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Story Points") issueLinkManager.getOutwardLinks(issue.id).findAll { it.issueLinkType.name == "Epic-Story Link" }.findAll { it.destinationObject.status.name in doneNames }.each { totalSP += it.destinationObject.getCustomFieldValue(customField) as Double ?: 0.0 } return totalSP as Double
(untested).
Thank you Jamie!
It is working great.
The only change which I made is: !(it.destinationObject.status.name in doneNames) as I want all issues not in status Done.
Thanks once again!
Paulina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.
Get Certified! ✍️Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.