Create and Modify JSM Behaviours
Create a JSM Behaviour
- Navigate to ScriptRunner > Behaviours.
You will see a list of any previously created behaviours.
- Click Create Behaviour and choose the JSM Behaviour option.Tip:
If you do not have user permissions for the jira-servicemanagement-users group, you will see a warning message displayed:
Click Edit user permissions to open the Jira admin settings, then add your name to the jira-servicemanagement-users group. Keep in mind that the full group name includes an instance-specific suffix, such as jira-servicemanagement-users-<instance-name>.
- Enter a name and description for the behaviour. It's good practice to make these as descriptive as possible.
- Choose where the behaviour rules will apply from the Step 1: Location options.
- Select the spaces to which the behaviour will be applied from the list of available Spaces.
- Select the request type to which the behaviour will be applied from the list of available Request Types
- Select the view type to which the behaviour will be applied from the list of available View Types.
Tip: JSM is supported on Portal view only. Due to an Atlassian limitation, Agent view is not supported at this time, but will be available soon.Tip: At least one option must be selected from each category, and you have the option to choose Select allif required. - Determine when the behaviour script will run by choosing the trigger that controls when the script executes from either On load or On change (or both) from the Step 2: Trigger options.
When Run On load The script will run when the chosen view type screen initially loads. Choose this option when you want the affected field to populate immediately upon opening the chosen view type 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. 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.. - Enter your code within the script box of the Step 3: Rules section, as required. If needed, you can open the API documentation directly from here.Tip: JSM Behaviours support only one script per Behaviour. If you need to use multiple scripts, you can create a separate Behaviour for each one. This approach makes your Behaviours easier to manage and aligns with our recommended best practice of using one primary use case per Behaviour. Jira Behaviours will soon move to this same single-script model as well.
Alternatively, you can reuse one of the example scripts provided and modify the code as required, ensuring that you:
- Edit any variables, such as custom field names, roles, or groups, so the script matches your Jira configuration.
- Choose the right time to run your script on load and/or on change so that it runs when needed.
To choose an example:
- 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.
- View the script and click Copy Cloud script.
- Return to the script box and paste the copied script into the script editor.
- Click Save and enable to confirm the configurations for your behaviour. You also have the option to Save and disable the behaviour so that it can be activated another time.
The Behaviour Logs allow you to view data related to ScriptRunner for Jira Cloud Behaviours that have run in your Jira instance.
Modify a JSM 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, as shown in the example below:
- Filter the list of behaviours using the options available, including: Fields, Spaces, Request Types, and View Types. You can use the search bar to enter a name or UUID, and the list can be sorted by Name and Jira or JSM behaviours..
- Click the Actions ellipsis next to your chosen behaviour, and you can modify it using 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 JSM Behaviour
- Click Edit from the Actions ellipsis next to the behaviour you want to modify.Tip: Click the Behaviour name to quickly navigate to the Edit Behaviour screen without opening the Actions ellipsis menu.
The Edit Behaviour screen opens, as shown in the example below:
- Scroll through this screen to make your required changes, such as:
edits to the name and/or description
changes to the selections previously made when creating this behaviour in Step 1 and/or Step 2
edits to the code. JSM Behaviours support only one script per Behaviour. If you need to use multiple scripts, you can create a separate Behaviour for each one.
Note: It is not possible to convert a JSM Behaviour to a Jira Behaviour when making edits. - Click Save changes when all modifications are complete. You will see a message confirming that your changes have been successfully saved.