Field Behaviours
Use Field behaviours to control how fields appear and function in specific spaces or work item types. You can use field behaviours to:
- Set a field value based on another field
- Change the name or description that is displayed for a field
- Show or hide fields for people in a specific role
Activity history
Saved field behaviours keep activity history, so you can review when they were run, and what the output was, making it easier to audit and troubleshoot.
When a script runs, the activity history shows:
- Anything logged with
console.log(...) - The final value returned by your script with
return
Use console.log(...) for messages, intermediate values, or debugging. A behaviour works by calling methods on api, so anything you return is recorded in the history for troubleshooting but has no effect on the form.
The difference between Jira and JSM field behaviours
Jira field behaviours run directly on Jira work item screens. You can apply them to multiple view types, including:
- Create – when a user creates a work item
- Transition – when a user moves a work item through a workflow transition
- View/Edit – when a user views an existing work item
This allows you to control and react to fields throughout the work item lifecycle within Jira.
JSM field behaviours can run in two places, and what is available depends on which one you target:
- Work item screens – the Create, Transition and View/Edit screens your agents use to work on requests. Target them by selecting a service desk space after selecting work item screens. All three view types are available, exactly as they are in Jira.
- The customer portal – the request form your customers fill in. Only the Create request view is available, so behaviours targeted at the portal do not run on transition or view screens.
Each set of screens you add targets one or the other, never both. A single field behaviour can have several sets, so one behaviour can cover work item screens and the customer portal.
Create a field behaviour
Follow these steps to create a new field behaviour:
Edit a field behaviour
Use these steps to modify an existing field behaviour:
Enable and disable a field behaviour
To enable or disable your field behaviour:
- In Jira administration, select Marketplace apps.
- Under Apps, select ScriptRunner.
- In ScriptRunner, select Field behaviours.
- Locate the field behaviour you want to enable or disable.
- Open the ellipsis (…) menu for that field behaviour and select Disable or Enable.
Delete a field behaviour
Remove field behaviours you no longer need to keep your list organized and reduce clutter. When you delete a field behaviour, it's removed from your active field behaviours list and will no longer run, but it isn't permanently removed. You can still access and restore it from ScriptRunner if needed.
To delete a field behaviour:
- In Jira administration, select Marketplace apps.
- Under Apps, select ScriptRunner.
- Select Field behaviours.
- Find the field behaviour you want to remove.
- Open the ellipsis (…) menu for that field behaviour.
- Select Delete.
- When prompted, confirm that you want to delete the field behaviour.
Restore a deleted field behaviour
You can restore deleted field behaviours along with their activity history. To restore a deleted field behaviour: