Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

229 views 2 1
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you