Versions Compared

Key

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

This page allows you to create Event-based actions, with one or more JMWE post-functions, that are run when a change is made to an issue, such as fields being modified, the issue being transitioned, a comment being added, etc.

Some examples of what can be achieved through Event-based Actions are:

  • Synchronizing changes to a field with related issues such as sub-tasks, linked issues, epics, etc.

  • Calculating the value of a field based on the values of other fields (view this demo)

  • Copying a comment added by a customer on a Service Management request to linked Jira Software issues

  • Validating data when a user edits an issue field on the issue view screen (view this demo)

On this page:

Table of Contents

Create an event-based action

To create an event-based action:

  1. Navigate to the Jira Settings → Apps → Event-based actions

  2. Click on "New event-based action"

    1. Add a name and an optional description

    2. Define the event to listen to (see below)

    3. Define the scope of the action (see below)

    4. Add the post-functions to run when the action is triggered (see below)

  3. Click on "Save"

Edit an event-based action

  1. Click on “Edit” for the event-based action

  2. Modify the action details

  3. Click on “Save”

Delete an event-based action

  1. Click on “Delete” for the event-based action

  2. Click on “OK”

  3. The event-based action is deleted.

Enable/disable an event-based action

  1. Click on “Disable” if the event-based action is currently enabled, or “Enable” if the event-based action is currently disabled

  2. Click on “OK”

  3. The event-based action is enabled or disabled.

Event to listen to

Configure which Jira event should trigger this Action. You can listen to the following events:

  • Issue Created: this is triggered when a new issue is created, including when an issue is cloned.

  • Issue Updated: this is triggered when an issue is modified, such as being edited or transitioned.

  • Issue Commented: this is triggered when a comment is added to an issue

  • Issue Transitioned: this is triggered when a transition is performed on an issue. You can optionally filter the source and/or destination statuses of the transition.

  • Issue Field Value Change: this is triggered when one of the fields you have selected is modified on an issue

Ignoring app-related events

You can choose to ignore events resulting from changes performed by JMWE post-functions and Actions, by Jira Automation rules, or by other apps. For example, if you have configured an event-based action to listen to the Issue Commented event, you might care only about comments created by users, and want to ignore comments created by a Comment Issue(s) post-function or an Automation rule.

To ignore events caused by JMWE post-functions and actions, check the Ignore events caused by JMWE post-functions and actions checkbox.

Likewise, you can choose to ignore events resulting from changes performed by a Jira Automation rule or by another app. For that, check the Ignore events caused by Jira Automation and other apps checkbox.

Scope

Filtering by project and issue type

You can choose to apply an event-based action only to certain projects and/or issue types. This will usually result in better performance.

To apply the event-based action only to certain projects, select one or more projects under Projects. If you don’t select any project, the event-based action will apply to issues from all projects.

To apply the event-based action only to certain issue types, select one or more issue types under Issue types. If you don’t select any issue type, the event-based action will apply to issues of all types.

Filtering using a JQL expression

You can choose to apply an event-based action only to issues that match a JQL filter. The action will only run on issues that match the JQL filter.

Input a JQL search that will return the issues on which the action should be run. To input a JQL:

  1. Check the “Only apply to issues that match a JQL filter” checkbox

  2. Click on "Edit JQL"

  3. Input a JQL expression that will return the issues on which the action should be run. See here to know how to write a JQL. For example:

    Code Block
    languagesql
    project =  TEST and issuetype = Bug
  4. Click on "Search" to check the issues returned by the JQL. It is recommended to check the results of the JQL to avoid invalid JQL.

  5. Click on "Submit"

Filtering using a Nunjucks condition

You can choose to apply an event-based action only to issues that match a Nunjucks condition. The action will only run on issues for which the Nunjucks template returns true (or any value that is neither empty nor false).

  1. Check the “Only apply to issues that match a Nunjucks condition” checkbox

  2. Input a Nunjucks template that will return true (or any value that is neither empty nor false) for any issue on which the action should run. For example:

    Code Block
    languagesql
    {{ issue.fields.project.key == "TEST" and issue.fields.issuetype.name == "Bug" }}

Post-functions

Whenever the event is triggered by Jira, and if the issue belongs to the Scope defined above, the configured post-functions will be run, in the order in which they appear. You can reorder the post-functions by dragging them using the ☰ handle.

Add a post-function in an action

  1. Click on “Add post-function”

  2. Select the post-function

  3. Configure the post-function

  4. Click on “Save”

Edit a post-function in an action

  1. Click on “Edit” for the specific post-function

  2. Modify the post-function

  3. Click on “Save”

Reorder the post-function sequence in an action

  1. Drag the ☰ handle and reorder the post-functions

Remove a post-function in an action

  1. Click on “Remove” for the specific post-function

Passing variables within a sequence

Using the {% setContextVar %} Nunjucks tag you can pass data from one post-function to all subsequent post-functions.

  • context: Holds all the context variables added in the current post-function. For example, if you create a context variable myVar in the first post-function of the sequence:

    Code Block
    languagejs
    {% setContextVar myVar = "a value" %}

    This variable will then be available to all its subsequent post-functions as:

    Code Block
    languagejs
    {{ context.myVar }}

    (warning) Note that this variable will not be available in the Nunjucks tester.

Variables specific to the Create Issue post-function

  • newIssueKey: Stores the issue key of the last issue created by a Create Issue(s) post-function in the action. You can access it as:

    Code Block
    languagejs
    {{ context.newIssueKey }}

  • newIssueKeys: Stores an array of the keys of all the issues created by any Create Issue(s) post-function in the action. You can access the created issues from

    Code Block
    languagejs
    {{ context.newIssueKeys }}

    For example: to add a comment on the current issue with the keys of the issue created

    Code Block
    languagejs
    Issues created are:
    {{ context.newIssueKeys | join(",") }}

You can access the information of a specific issue using the issue filter. For example: To get the assignee of the issue created by the Create Issue post-function

Code Block
languagejs
{{ context.newIssueKey | issue("assignee") | field("fields.assignee.displayName") }}

Error handling

If one of the post-functions fails with an error, the remaining post-functions in the sequence are run anyway. To stop the execution of subsequent post-functions after an error occurs, select the option “Skip subsequent post-functions if a post-function encounters an error”.