Script Field Tutorial
ScriptRunner gives you the ability to create custom fields that rely on an underlying script with a feature called script fields. At the time of this writing, ScriptRunner includes four pre-built custom fields, as well as the ability to apply a custom (or in-line) script to an entirely new field.
This feature is located in the Manage Apps page. ().
The eight types of script fields available are:
- Custom Script Field
This is the function you'd use to create a new custom field and script.
- Date of First Transition
Displays the date that an issue was first moved to a designated status.
- Issue(s) Picker
Allows you to select another issue, optionally constrained by a JQL query.
- No. of Times in Status
Deploying this field informs users of how many times an issue has been in a designated status.
- Show Parent Issue in Hierarchy
This field displays the parent issue in the hierarchy, and can be configured to follow Portfolio parent field or alternate links.
- Remote Issue(s) Picker
Select an issue(s) from a linked Jira instance, optionally constrained by a JQL query.
- Time of Last Status Change
The time stamp of the last status change is displayed in the issue.
- Database Picker
Pick an item from a linked database table.
Why Use Script Fields?
Script Fields can calculate or amalgamate data from one or more existing fields. When your users need calculations displayed in an issue, in reports, or they want to display other information that isn't readily available via custom fields, ScriptRunner script fields give you the ability to meet their needs.
Example of Script Field
In this example, we'll help Great Adventure managers gauge how many times issues are being sent to the In Progress status to determine whether or not excessive re-work is being done. If they find that there are issues, they can drill down and see what is causing the repeat work.
This field can now be searched using JQL. This permits any user to determine whether an issue has transitioned to the In Progress state more often than would be normal. For example, it could help Jira admins identify tasks managed by people who are not following the internal processes correctly (given that In Progress should not exceed a count of 6-10 before the issue is closed). It could also be used to help identify problems with workflow controls.
For more examples of script fields, see our Example Scripts.