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

Scripted Field - Global Values


I am working on writing a groovy script for calculating Epic Rollups. I would like to know is there any way of getting the global values for the user, issue assuming there is an epic?  

I want to use something like this,

USER = 'invinci'
children = retrieveIssuesInEpic(issue)
total = sumOfOriginalEstimates(children)


1. USER is the one with browse projects permissions

2. children represents the subtasks

3.  sumOfOriginalEstimates(children) is the time taken.


How would I let the script know of the parent/child key values whenever an issue is created on the jira web application?


Thank you!

2 answers

1 accepted

You don't invoke Script Fields. They are invoked when the issue is viewed. I use them heavily depending on the use-case.

Word to the wise: You should configure the custom field scope tightly for script fields. A script field can be a lot more expensive than say, a string text field. You should make sure the custom field context to only include projects and issue types that it's relevant for.

For example, this field would only be used by Software Development teams. You would only use this field on the Epic issue type. Your context should look something like this:

In addition to the custom field context, you should edit the custom field and change the searcher to Duration Searcher:

Your script should accomplish the following:

  • Set the view template to Duration
  • Disable the script field cache
  • Use IssueLinkManager to pass the Issue object and receive a list of IssueLinks
  • Using these IssueLinks, check each IssueLink object for the IssueLinkType, as you only want issues linked via the Epic-Story Link type
  • For each IssueLink object, use the getDestinationObject() method to obtain the Issue object for that linked issue
  • For each object, use the getOriginalEstimate() method to obtain the estimate time
  • Sum all of these original estimates
  • Return the value

An example of what this script could look like is below. I'm no groovy expert. I do not know what version of JIRA you're using and I do not know how you want your data presented, so this may not work for you. This doesn't consider sub-tasks, so you'll likely want to obtain the aggregate estimate instead. I didn't have the time to complete this though: I just mostly took an existing field I had and modified it.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.issuetype.IssueType
import com.atlassian.jira.config.IssueTypeManager

enableCache = {-> false}

IssueType getIssueTypeByName(String name){
 for(IssueType issueType in ComponentAccessor.getComponent(IssueTypeManager.class).getIssueTypes()){
        if(issueType.getName() == name){
            return issueType
    return null

String issueTypeName = "Epic"
String issueLinkTypeName = "Epic-Story Link"

IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
IssueLinkTypeManager issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager.class)

IssueLinkType[] issueLinkTypes = issueLinkTypeManager.getIssueLinkTypesByName(issueLinkTypeName)
IssueLink[] issueLinks = issueLinkManager.getOutwardLinks(

IssueType issueType = getIssueTypeByName(issueTypeName)

if( issue && 
    issueType && 
    issueLinkTypes.size() > 0 && 
    issue.getIssueType().name == issueType.getName() && 
    issueLinks.size() > 0 )
    List<IssueLink> relevantIssueLinks = new ArrayList()
    for(issueLink in issueLinks){
        if(issueLink.getIssueLinkType().name == issueLinkTypes.first().getName()){
    if(relevantIssueLinks.size() > 0){
        Long originalEstimate = 0
        for(issueLink in relevantIssueLinks){
            Issue linkedIssue = issueLink.getDestinationObject()
                originalEstimate = originalEstimate + linkedIssue.getOriginalEstimate()
if(originalEstimate > 0){ return originalEstimate
} } } 


hey Steven, 

Thanks for the detailed explanation. Now I get the idea of how to work on my script. 

Thanks a lot! 

It's unclear to me: Is this a listener? You want this to execute on Issue_Created/Issue_Updated?

It is a Scripted Field which is invoked on issue events

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

142 views 1 3
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