work remaining in epic with story points

Daniel Tombs May 17, 2017

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

 

1 answer

1 accepted

2 votes
Answer accepted
Aidan Derossett [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 17, 2017

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:

  • Create a Script Field and ensure that it is only mapped to the Epic issue-type and to any screens that you would like.
  • Navigate to the Add-ons page under the Administration section and click the Script-Fields link on the side-bar to the left of the screen.
  • From there, hit Edit on your new Script Field and fill in the necessary information; including the code. Make sure that you are using a Number template.
  • Save your Script Field and you should be good to go!
Chris_Fortuin June 25, 2018

I followed your instructions but get an error for summations using "+=" and stating "cannot find matching method" so any suggestions for a fixing this?

Aidan Derossett [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 26, 2018

Hey there Chris!

Could you send me a screenshot of the error that you're receiving? :) 

Chris_Fortuin June 26, 2018

Hi Aidan, see below the error I get for line 12 and 19 in the scripted field.

JIRA - Script Fields Error.png

Aidan Derossett [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2018

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

Suggest an answer

Log in or Sign up to answer