Create and Modify Behaviours
Create a Behaviour
The steps below describe how you can create a new behaviour from the Behaviours app:
- Navigate to ScriptRunner > Behaviours. You will see a list of any previously created behaviours.
Click Create Behaviour. The following screen displays:
- Enter a name and description for the behaviour. It's good practice to make these as descriptive as possible.
- Toggle on the Enable Behaviour option, as required. By default, the behaviour is set to Enabled, meaning that the behaviour is active as soon as it has been saved.
- Select the spaces to which the behaviour will be applied from the Spaces drop-down list. At least one space must be selected, and you have the option to select All spaces if required.
Select the type of work item you want to apply this behaviour to from the Work Types drop-down list. At least one work type must be selected, and you have the option to select All work types if required, which displays the maximum work types available.
Behaviours mapping with wildcards
You can select the wildcard option for either All spaces or All work types only; due to an Atlassian limitation, both options cannot be chosen simultaneously.
If you choose All spaces or All work types, any new spaces or work types added to your instance will automatically be included in the Behaviour. However, if you manually select all the current spaces or work types instead of using the global All options, then you must manually add these to the mapping, as they won't be automatically included.
Click Add Script. You will see the Add Field Script pop-up window appear, where you can add the behaviour script.
You can use the Fullscreen option to open the code editor in full-screen mode, and click Exit Fullscreen to return to the original size.Determine when the behaviour script will run by choosing either On load or On change (or both) from the Run the script options.
When Runs On load The script will run when the create screen initially loads.
You'll want to choose this option when you want the affected field to populate immediately upon opening the create screen.
For example, a field name or description can be changed, or a value can be pre-populated into the field.
On change The script will run when the specified supported field change happens. You may want to run the script initially when it loads, AND if a change has occurred.
You'll want to choose this option when you've added a condition to the logic and identified a trigger that will update the affected field. So, if you want to run the script after the user alters a field on the create screen, you should choose the On change option.
For example, initially, you could set the assignee field to Bob, so all new bugs are assigned to them, but if the user changes the priority to High, the assignee would auto-update to Jane.Choose to run the script on either the Create, View/Edit, or Transition (or multiple) view types from the and on options. Refer to Behaviours Supported Fields and Products, as not all field types are supported.
Enable Transition View Per Screen
Selecting the Transition View option will enable the behaviour for all transition screens by default. If you want it to apply to a specific transition screen, then you need to specify the transition ID of that specific screen. To find that ID, go to Settings and select Work Items > Workflows > View and locate the Transition Id column, where you will find the specific ID to use in your script. For example,
// The transition ID for Done const transitionToDone = 41; // Get current transition ID const transitionId = await getContext().then(context => context.extension.issueTransition.id); // If the current transition is to Done then do something if (transitionId == transitionToDone) { }- Enter your code within the script box, as required. Note that you can open the API documentation directly from here.
Alternatively, you can reuse one of the many example scripts provided and modify the code as required, ensuring that you:- Edit any variables, like custom field names, roles, or groups, in the example code so it's relevant to your instance.
- Choose the right time to run your script on load and/or change so that it runs when needed.
- Click Example scripts, and you are automatically redirected to the ScriptRunner HQ website, where you can view the Behaviours example scripts.
- Choose your preferred script from the examples provided. You also have the option to search for a particular script.
- Open the script and click Copy Cloud script.
- Return to the script box and paste the copied code into the code editor.
- Click Save Script to save your behaviour script. Once saved, you will see the details displayed within the Behaviours Scripts table:
You can use the Action ellipsis menu to Edit or Delete the script. If you want to continue adding more behaviour scripts, these must be defined separately, as outlined in the steps above. You can continue to add these to the table and add the logic needed until your business requirements for this behaviour are met. - Click Save to confirm the configurations for your behaviour, or you can Cancel.
The Behaviour Logs allow you to view data related to ScriptRunner for Jira Cloud Behaviours that have run in your Jira instance.
Modify a Behaviour
Follow the steps below to make changes to existing behaviours in ScriptRunner for Jira Cloud:
- Navigate to ScriptRunner > Behaviours. A list of previously created behaviours displays.
You can search for a specific behaviour using the search bar by entering its name or UUID. The list of behaviours can be sorted by name and filtered using the available options—such as Affected Fields, Spaces, or Work Types—to help narrow down the list, for example: - Click the Actions ellipsis next to your chosen behaviour, and you can choose from the following options:
- Edit - opens the Edit Behaviour screen.
- Copy UUID - copies the UUID, which you can use in the search bar.
- Disable - makes the selected behaviour inactive. Disabled behaviours are clearly marked in the list.
- Delete - removes the behaviour if it is no longer in use.
Edit a Behaviour
- Click Edit from the Actions ellipsis next to the behaviour you want to modify.The Edit Behaviour screen opens, allowing you to make changes to any of the sections included here, such as edit the name and description, toggle the behaviour on or off, map to spaces and work types, and work with scripts.Click the Behaviour name to quickly navigate to the Edit Behaviour screen without opening the Actions ellipsis menu.
All spaces OR all work types
You can select all spaces or all work types, toggle seamlessly between them, and apply all options without manual configuration.
- Scroll to Behaviours Scripts and open the Actions ellipsis menu next to the Affected Field you want to edit. You can also delete each of the individual Behaviour Scripts via the Actions menu.
- Click Edit, and you will see the Edit Field Script window displayed. You can use the Fullscreen option to open the code editor in full-screen mode, and click Exit Fullscreen to return to the original size.
- Make the changes, such as modifying when the script runs, the type of view used, and/or editing the script code.
Enable Transition View Per Screen
Selecting the Transition View option will enable the behaviour for all transition screens by default. If you want it to apply to a specific transition screen, then you need to specify the transition ID of that specific screen. To find that ID, go to Settings and select Work Items > Workflows > View and locate the Transition Id column, where you will find the specific ID to use in your script.
For example,// The transition ID for Done const transitionToDone = 41; // Get current transition ID const transitionId = await getContext().then(context => context.extension.issueTransition.id); // If the current transition is to Done then do something if (transitionId == transitionToDone) { } - Click Save to confirm the configurations for your behaviour.









