[All Adaptavist Apps]

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Note

In order to use the 

Excerpt
hiddentrue

Learn all about Behaviours in ScriptRunner for Jira CloudBehaviours feature, you must install ScriptRunner for Jira Cloud and then proceed to install a separate ScriptRunner Behaviours Forge app. It is important to follow the correct sequence for these installations as the Behaviours features will not work if you install the app before installing ScriptRunner for Jira Cloud. If this does happen, you can uninstall and reinstall the Behaviours app. As an existing ScriptRunner customer, the ScriptRunner Behaviours Forge app is free to use.

What are Behaviours?

Behaviours give you more control over fields in Jira. A field configuration customizes how fields behave across an instance. However, a behaviour in ScriptRunner for Jira Cloud allows you to take that field customization further, defining how fields behave for issues in a given project or issue context.

...

Behaviours let you extend the standard field configuration options available in Jira and give you the power to use contextual information like current field values, workflow step name, or user details as conditional logic.provide you with options that enable you to customize how fields in Jira behave. Therefore, you can give your users clear direction when filling in fields on the Create Behaviour screen. For example, you may want to create a behaviour that hides a field for a specific user until it's relevant for that user to interact with that particular field. 

You can create a behaviour that willYou can create behaviours to:

  • Prefill/preformat a template for users to follow template when an issue is created so users can easily follow it.

  • Make a custom field read-only depending on the workflow state.

  • Dynamically make calls to external data sources based on user selections when an issue is created.

  • Hide a custom field depending on the value of another custom field.

...

  • Change the name that is displayed for a field.
  • Hide or show a supported field only to people in a specific role.
  • Set a field value based on another supported field.

Behaviours Supported Fields

Behaviours can be applied to supported fields on the Global Issue Create view only. Additionally, conditions may only be set on the following supported fields:

  • Summary 
  • Description
  • Assignee
  • Priority
  • Labels 

Logs

ScriptRunner allows you to view and download logs for the last 'X' days, providing you with insights into the behaviours that have run over that period. If you need to view logs prior to the available date, you can contact your Jira site admin, where they can view it from the site admin settings. 

Data Residency

Data residency gives organizations more control over their data by ensuring their user-generated content is stored within the US or the EU. Currently, we do not support data residency for the ScriptRunner for Jira Cloud Behaviours feature as the app is built using Atlassian Forge, which doesn't yet support data residency. Behaviours configs are stored in our S3 bucket according to the region where ScriptRunner is installed. The Behaviours logs are stored in elastic which also does not support data residency. As Forge does not support data residency, then anything stored there, such as UI modifications/app variables, also does not support data residency.

How to use Behaviours

Behaviours in ScriptRunner for Jira Cloud can be used to reinforce your business processes. It's beneficial to think of a behaviour as one of your business rules or use cases and understand that it will only affect fields on projects and issue types specified by you.

Within the behaviours feature, you can choose to change or alter one or more fields. These are known as the Affected Fields and are essential to initiate a behaviour. As such, they must be defined from the outset and are mandatory. Additionally, it is essential to determine the timing of when the script on the affected field should run: when the create screen first loads or when a change has been made to another field.

Info

A fundamental difference between the ScriptRunner for Jira Server/DC and ScriptRunner for Jira Cloud behaviours feature is that the field selected is the trigger that causes the behaviour to run in ScriptRunner for Jira Server/DC. However, with ScriptRunner for Cloud, you choose an affected field first and then write a script with logic that will alter that field in your preferred way.

Install the app
Anchor
Install the app
Install the app

Why?

There are currently two platforms on which Jira apps can be built: Atlassian Connect and the newer Atlassian Forge. ScriptRunner for Jira Cloud is built on the Connect platform, but this does not facilitate the Behaviours feature. Atlassian created an API called UI Modifications on the Forge platform, which made it possible for ScriptRunner to build behaviours. Therefore, this means that in order to use the Behaviours feature, a separate Forge app needs to be installed alongside ScriptRunner for Jira Cloud. 

As more capabilities become available in the UI Modifications API, more functionality can be built in ScriptRunner's Behaviours feature. 

How?

To install the ScriptRunner Behaviours Forge app, follow these steps: 

  1. Log into your Jira instance as an admin. 
  2. Ensure you have installed ScriptRunner for Jira Cloud.
  3. Locate the Behaviours tab
    Image Added
  4. Click Install Free App.
  5. Navigate back to ScriptRunner and open the Behaviours tab.
    After the app has been successfully installed and you have refreshed your instance, you will see the initial landing screen as shown below:
    Image Added
    From here, you can click Create Behaviour and follow the steps to create a behaviour in ScriptRunner for Jira Cloud outlined below.
Info
Currently, if Forge apps are uninstalled, then you will no longer have access to that data. However, if you uninstall the Behaviours app, ScriptRunner will continue to store your data, so if you decide at a later time to reinstall it, your data will still exist

...

.

Before you start

Column
width45%

Image Modified***Our training module helps you learn how to set up and use behavioursBefore setting up a behaviour, read about Jira field configurations.

Column
width10%


Column
width45%

Image Removed

***Before you set up a behaviour be sure to read about the Behaviour Limitations. This can also help troubleshoot getting your behaviour to work.Image Added
Understand Atlassian's UI Modifications API.

Section
Column
width45%

Button Hyperlink
custom-iconshortcut
iconcustom
titleBehaviours TrainingField Configurations in Jira
typeprimary
urlhttps://docsconfluence.adaptavistatlassian.com/sr4js/latest/training/course-introduction-to-scriptrunner-for-jira-data-center-server/1-2-video-using-behaviours-in-scriptrunner-for-jira-data-center-serveradminjiraserver/specifying-field-behavior-938847255.html?_ga=2.154855672.1347100514.1658738350-964472448.1651132762
targettrue

Column
width10%


Column
width45%

Button Hyperlink
true
custom-iconshortcut
iconcustom
titleUI Modifications API Limitations
typeprimary
urlhttps://docsdeveloper.adaptavistatlassian.com/platform/sr4jsforge/latestmanifest-reference/features/behaviours/behaviour-limitationstargetmodules/jira-ui-modifications/?&_ga=2.98405596.2126852167.1658305154-1447894465.1652947992#known-limitations
targettrue

Create a Behaviour
Anchor
Create a Behaviour
Create a Behaviour

Note

Some points worth noting about behaviours from the outset: 

  • The language used when writing the logic for behaviours scripts is Javascript and not Groovy.
  • Each behaviour's script cannot exceed 5,000 characters.
  • Complex scripts may affect the speed at which your behaviours run, and they may be slower than simple or efficient scripts. 
  • Currently, you can only make GET REST requests to the Jira Cloud REST API.
  1. Navigate to ScriptRunner → Behaviours.
    If you have previously created behaviours, you will see a list displayed. You can choose to edit or delete any of these via the Actions ellipsis next to the behaviour you would like to modify or delete.
  2. Click the Create Behaviour button. The following screen displays:
    Image Added
  3. Enter a name in the Behaviour Name field.
  4. Enter a brief summary of the behaviour's purpose in the Behaviour Description box.
  5. Check 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.
  6. Select the project(s) that the behaviour will be applied to from the Projects drop down list. You must select at least one project.
  7. Select the type of issue you want to apply this behaviour to from the Issue Types drop down list. You must select at least one issue type.
  8. Click the Add Field button to choose the field the behaviour will affect - this is called the Affected Field. You will see the Select Affected Field pop up window displayed where you can choose an Affected Field

    Info
    The Affected Fields are fields that are being changed or altered. They are not the fields that act as triggers for the changes or alterations.

    Image Added

  9. Select the field from the Affected Field drop down list and click Next. You will now see the following screen:
    Image Added
  10. Determine when the behaviour script will run, either On load or On change (or both). If you would like to run the script:
    • immediately upon creating a new issue, then choose the On load option.
    • after the user alters a field on the create screen, then choose the On change option.
      You may want to run the script initially when it loads AND if a change has occurred. For example, initially you could set the priority of bugs within a specific project to low, but if the user then selects, say, Escalate from a custom field, the priority could then be set to high.
  11. Enter your code within the Script box, as required. Alternatively, you can select an example script from the Insert Example Code drop down list and modify it 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 on change so that it runs when you need it to.
    Note
    Choosing to use the Insert Example Code script will replace anything that is already contained within the Script box. 
  12. Click Add to save your script for the Affected Field. You can also click the Back button to go back through your steps, or you can Cancel.
    If you would like to continue adding more affected fields, then these must be defined separately, as outlined in the steps above. You can c
    ontinue to add these to the table and add the logic needed until your business requirements are met for this behaviour.
  13. Click Save to confirm the configurations for your behaviour, or you can Cancel.

Edit a Behaviour

Follow the steps below to edit a behaviour in ScriptRunner for Jira Cloud:

  1. Navigate to ScriptRunner → Behaviours. You will see a list of previously created behaviours.
  2. Click Edit from the Actions ellipsis next to the behaviour you would like to modify. From here, you can also Delete a behaviour.
    Image Added
  3. Edit the fields, as required, from within the Edit Behaviour screen.
    Image Added
    You can edit or delete each of the individual Behaviour Fields via the Actions ellipsis
  4. Click Edit next to the Affected Field you want to edit, and you will see the Edit Affected Field window displayed:
    Image Added
  5. Make your required changes and click Next.
    Image Added
  6. Modify when the script runs and/or edit the script code, as required.
  7. Click Save to confirm the configurations for your behaviour, or you can Cancel. You can also click the Back button to go back through your steps, or you can Cancel.