Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,701
Community Members
 
Community Events
185
Community Groups

Script Runner help needed

Edited

Hello,

We have a need for a script that calculates all Story Points for any project/issue/linked/sub-task under it.


So if we have an issue with lots of other issues linked to it in any way, the need is to calculate ALL the Story Points for all those tickets and any sub-task or other linked issues under there and so on...basically a top down total count.

Looking so far only gets me small snips of either getting per story or per issue type or per link. Hoping some of you can help get me a grab all values?

Thanks again in advance.

(below is what I have now that will only get items from the same issue, not to mention line 7 and 10 are throwing an error in the ScriptRunner's Scripted Field code validator)

import com.atlassian.jira.component.ComponentAccessor

def issueLinkManager ComponentAccessor.getIssueLinkManager()
def customFieldManager ComponentAccessor.getCustomFieldManager()
def StoryPoints customFieldManager.getCustomFieldObjectByName("Story Points")
def totalSP 0
totalSP += issue.getCustomFieldValue(StoryPoints)?:0
issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->
    def linkedIssue issueLink.getDestinationObject()
            totalSP += linkedIssue.getCustomFieldValue(StoryPoints)?:0
    }
return totalSP



1 answer

Perhaps this may help you....this does similar but with values found on issues related to a separate project that is queried through JQL. Regardless, the outcome is a sum of all values pertaining to the Estimated Remaining Hours (getEstimate). I would assume this is similar to getting story points

 

import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.bean.PagerFilter

def customFieldManager = ComponentAccessor.getCustomFieldManager()

// gets value of Custom Field ProjectKey
def projectKeyField = customFieldManager.getCustomFieldObjectByName("ProjectKey");
def projectKey = issue.getCustomFieldValue(projectKeyField)

//completes JQL query from Custom Field "ProjectKey"
def searchService = ComponentAccessor.getComponent(SearchService)
def jql = "project = '"+ projectKey+"'"
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issues = []

//runs query and populates array with all of the Estimated remaining hours for each issue for the custom project key
SearchService.ParseResult parseResult = searchService.parseQuery(user, jql)
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())

issues = searchResult.issues.collect { ComponentAccessor.issueManager.getIssueObject(it.id).getEstimate()/3600 }

}

def total

//sums all values in array
total = issues.sum()

//an array with the issues returned from the JQL
return total

Thanks Joel, 

I will tinker with this and see how it goes.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events