on the adaptavist website (here), there is a page that shows how you can track how much work there is in related issues. but i was wondering how you would turn that script, so it would actually show how many story points are left in a particular epic.
I am guessing here, but i am pretty sure i would need my epic link ID number; 10006
and instead of searching for
issueLinkManager.getOutwardLinks(issue.id).each {issueLink ->
i would need
issueLinkManager.getOutwardLinks(issue.id).each {storyLink ->
then, i am pretty sure instead of;
if (issueLink.issueLinkType.name == "Composition") { def linkedIssue = issueLink.destinationObject totalRemaining += linkedIssue.getEstimate() ?: 0
i would replace ussielinktype.name with the story point id number and then somehow be asking the script to get all story point values from all linked issues and add them. but this is far as my knowledge goes
can anyone help?
thanks
(complete original script below)
package com.onresolve.jira.groovy.test.scriptfields.scripts import com.atlassian.jira.component.ComponentAccessor def issueLinkManager = ComponentAccessor.getIssueLinkManager() def totalRemaining = 0 issueLinkManager.getOutwardLinks(issue.id).each {issueLink -> if (issueLink.issueLinkType.name == "Composition") { def linkedIssue = issueLink.destinationObject totalRemaining += linkedIssue.getEstimate() ?: 0 } } // add the remaining work for this issue if there are children, otherwise it's just the same as the remaining estimate, // so we won't display it, if (totalRemaining) { totalRemaining += issue.getEstimate() ?: 0 } return totalRemaining as Long ?: 0L
Hey Daniel, I think something like this should work for you:
import com.atlassian.jira.component.ComponentAccessor def issueLinkManager = ComponentAccessor.getIssueLinkManager() def cfManager = ComponentAccessor.getCustomFieldManager() def cfStoryPoints = cfManager.getCustomFieldObjects().find{it.name == "Story Points"} log.warn("This: "+cfStoryPoints.name) def StoryPointsRemaining = 0 issueLinkManager.getOutwardLinks(issue.id).each {storyLink -> if (storyLink.issueLinkType.name == "Relates") { def linkedIssue = storyLink.destinationObject StoryPointsRemaining += linkedIssue.getCustomFieldValue(cfStoryPoints) ?: 0 } } // add the remaining work for this issue if there are children, otherwise it's just the same as the remaining estimate, // so we won't display it, if (StoryPointsRemaining) { StoryPointsRemaining += issue.getCustomFieldValue(cfStoryPoints) ?: 0 } return StoryPointsRemaining as Long ?: 0L
It's close to what you were describing above, but a couple other changes were necessary to ensure it was functioning properly.
The "if" statement that specifies the link type is arbitrary and can be removed if you would like the field to be calculated for issues that are linked by any type.
To set this up:
I followed your instructions but get an error for summations using "+=" and stating "cannot find matching method" so any suggestions for a fixing this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey there Chris!
Could you send me a screenshot of the error that you're receiving? :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Aidan, see below the error I get for line 12 and 19 in the scripted field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey again @Chris_Fortuin!
I actually think that that error may be benign. Often times, errors like these will be thrown in the inline editor because of the Static Type Checker's inability to determine the type of an Object at compile time. That's probably why it's yelling at you :)
Try testing the script regardless of the error and see if it still works for you.
Best of luck,
Aidan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.