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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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

Calculate the Sum of a Custom Field in Linked Issues in Scripted Field

Hello Atlassian Community,

I would like to calculate the sum of Story Points in all linked Issues with a scripted field via ScriptRunner. I´ve found this script:

and adjusted it to my use case like this: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

// The issue type for which we want the scripted field to be displayed
final issueTypeName = 'Story'

// The linked issues with that issue type will used

final linkedIssueType ???

// The values of that custom field - of type number - we want to sum up
final numberOfUsersFieldName = 'Story Points'

if ( != issueTypeName) {
    return null

def linkedIssues = ComponentAccessor.issueLinkManager.getOutwardLinks( { == linkedIssueType }
if (!linkedIssues) {
    return null

def numberOfUsersField = ComponentAccessor.customFieldManager.getCustomFieldObjects(linkedIssues.first().destinationObject).findByName(numberOfUsersFieldName)
if (!numberOfUsersField) {
    log.debug "Custom field is not configured for that context"
    return null

linkedIssues*.destinationObject.sum { Issue it -> it.getCustomFieldValue(numberOfUsersField) ?: 0 }
The only thing I couldn´t adjust without an error message is, that I don´t got an explicit "linkedIssueType". As I mentioned in the beginning, it should calculate all linked issues, not an specific type. 
Does someone got an idea how to modify this script? I would be pleased about any tips.
Best regards,

1 answer

1 accepted

1 vote
Answer accepted

Welcome to the Atlassian Community!

Just drop the code that looks for a specific type, and work with the full list of all links the "get" returns.

Hi @Nic Brough -Adaptavist-

I admit that I´m not a dev, but it worked after some trials. Thanks for your help!

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events