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
Community Members
Community Events
Community Groups

Script Runner help needed



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( {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.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 =, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())

issues = searchResult.issues.collect { ComponentAccessor.issueManager.getIssueObject( }


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
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

179 views 1 6
Read article

Atlassian Community Events