work remaining in epic with story points Edited

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

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!

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

Hey there Chris!

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

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

JIRA - Script Fields Error.png

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
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26,475 views 2 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you