We are going to create a Script Field that contains information from the issues that have been linked to it. This is quite useful when you want to display your data in JQL filters, or when you want to take a better look at information across issues that are linked.

In order to create this field, follow these steps:

  1. Fetch all the issues that make up an Epic.
  2. Collect a certain set of information.
  3. Display that information in a table within the issue in a Script field.

We will use the following ScriptRunner features:

  • Script Fields
  • HTML Templates

In the end, you will have a fully functional script field, for example:

This field, will allow you to fetch this information in a filter, like so:

You can do something simple, as in this example, or you can even include other complex data, such as estimates, story points, etc. This is very useful to define what a summary of your issues is.

Basics

These are a basic functionality of ScriptRunner, they allow you to execute a groovy script every time you view an issue and returning a value that is based on whatever you want. They are designed to calculate values based on other issue fields.

Possible examples of information that could be displayed using script fields, from the easiest to the most difficult:

  1. Link to another project.

  2. Due date based on the priority of the issue.

  3. Link to another platform based on a combination of the issue fields.

  4. Calculate priority based on a combination of issue fields.

  5. Display the Bamboo build status for the development branch associated to the issue.

Limitations

Since the script is executed every time the issue is viewed, that means that the script fields cannot be used to index the issue. What does this really mean?

Imagine the next scenario. You are calculating a text priority, only for display purposes:

  • Displays a priority from 1 to 5,
  • Based on the date of creation and an external component to Jira, for example a Bitbucket commit date.

And you want to be able to fetch this information in a JQL query, and order by it. This is possible, but the information might be out of date.

The reason behind it is that Jira usually indexes every time there is a change in fields, a transition, or something else. This "indexing" means that it orders the issue based on its fields. However, bear in mind that the script field is recalculated every time the issue is viewed, unless caching is enabled. In order to learn more about catching, check out the documentation article about Script Fields