The Adaptavist Group LogoDocumentation

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:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. Select Field behaviours.
  4. Select Create.
  5. Enter a Name and, optionally, a Description.
  6. Select Add screens to configure where your behaviour applies to:
  7. In the Choose where it applies section, configure where your field behaviour applies:
    1. Choose the screens the behaviour runs on:
      • Work item screens: Create (new work item dialog), Transition (status change screens), and View/Edit (viewing or editing a work item).
      • Customer portal: Create request (the customer-facing request form).
    2. Choose the Spaces and Work types the behaviour applies to.
    3. Select Add screens to save the set. You can add more than one set of screens.
      Note: Work types across multiple spaces

      When you select more than one space, work types are combined by name: you see a single option per work type (for example, one Task), not a separate entry for each space. If the same work type exists in more than one selected space, the option shows which spaces it applies to. You can also select All work items to apply the behaviour to every work type.

      You cannot select All Jira spaces and All work items in the same set of screens. Narrow either the spaces or the work types so the behaviour targets a specific set.

  8. Write your script.
    Tip: To help you write scripts, you can use the field behaviour examples, or select Example scripts directly in the script editor. Field behaviours run in the browser, so only part of HAPI is available: issues, fields, projects and paginated-iterator.
  9. Select Publish.

Edit a field behaviour

Use these steps to modify an existing field behaviour:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. Select Field behaviours.
  4. Find your field behaviour in the list and select Edit.
  5. Modify the field behaviour as needed.
    Your changes are saved automatically as a draft. The published version keeps running until you publish again.
  6. Select Publish.

Enable and disable a field behaviour

To enable or disable your field behaviour:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. In ScriptRunner, select Field behaviours.
  4. Locate the field behaviour you want to enable or disable.
  5. 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:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. Select Field behaviours.
  4. Find the field behaviour you want to remove.
  5. Open the ellipsis (…) menu for that field behaviour.
  6. Select Delete.
  7. When prompted, confirm that you want to delete the field behaviour.
Note: Deleted field behaviours can be restored, including their activity history.

Restore a deleted field behaviour

You can restore deleted field behaviours along with their activity history. To restore a deleted field behaviour:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. Select Field behaviours.
  4. Use the filter and select Deleted to view deleted field behaviours.
  5. Find the field behaviour you want to restore.
  6. Open the ellipsis (…) menu for that field behaviour.
  7. Select Restore.
    The field behaviour and its activity history will be available again in your active Field behaviours list.

Search documentation

Start typing to search the docs.