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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,003 views 12 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot