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!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

816 views 2 19
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