Script fields
Migrating to Jira Cloud? This feature has partial parity in Cloud. |
Before you start
See our training module to learn about setting up and using script fields. | |
Broaden your horizons by exploring the Example Scripts for script fields. |
What are script fields?
Script Fields are custom fields that dynamically calculate and display values based on built-in and custom scripts . They enable you to display information that would otherwise be unavailable for an issue by calculating or aggregating data from one or more existing fields.
How to use script fields
You could use a script field to:
- Pull in data from an external system (such as a connected database).
- Show a value from a linked instance.
- Show a value calculated from the values of other issue fields.
- Show a value calculated from the values of fields in other issues.
When writing a script, it's good practice to keep the scripts as simple as possible so as to reduce loading time.
Searchers
You can run a search on your script fields provided it has a Searcher associated with it.
A searcher is equivalent to the Search Template that come default with custom fields. Built-in script fields are automatically given a searcher. For most custom script fields you have to add your own searcher by selecting the searcher field, selecting the appropriate search template, and performing a re-index.
Available script fields
We have developed a number of built-in script fields for you to use in your Jira instance:
- Database picker: Pick an item from a linked database.
- Custom picker: Write your own picker, for example using a REST resource or a Jira object.
- Date of first transition: Shows the date when the field first transitioned into a required state.
- Issue(s) picker:Select another issue, optionally constrained into a required state.
- Number of times In status: Show the number of times a given issue has been in the selected status.
- Show parent issue in hierarchy: Show an issue's parent issue where you define what parent means.
- Remote issue picker: Select issue(s) from a linked Jira instance, optionally constrained by a JQL query.
- Time of last status change: Displays a timestamp of when the issue last had its status changed.
- LDAP picker: Pick an LDAP record(s) from a predefined query.
We have also created a number of custom script field examples you can use.
Create a script field
You can create a script field as follows:
Caching
The calculated value of a script field is cached for ten seconds and we can cache up to 40,000 objects. If you refresh an issue and don't see a change, it may be because you're seeing the cached value. If you wait more than ten seconds then it should reflect the updated value.
enableCache = {-> false}Performance and execution history
On the Script Fields page we provide Performance and History columns that display performance execution history records for custom script fields.
Please note that performance and execution history records are only available for custom script fields.Performance and History will remain blank in the rows of custom fields created from built-in scripts.