Assign and transition an issue when it is escalated
Goal | When an issue is escalated, automatically assign it and move through a Transition |
---|---|
Scenario | You want to begin work immediately when an issue is escalated. To do this, the issue will be assigned and automatically transitioned to the In Progress status, and a notification sent to the assigned user. |
Components | Event-based Action: Issue updated event, Assign issue(s) post function, Transition issue(s) post function |
Baseline |
|
You are viewing the documentation for Jira Cloud.
Requirements
JIRA Administrator login
A custom field called Escalated, or Jira Service Management (JSM) installed on your instance which includes the Escalated field. See Create a custom field | Atlassian Support for steps on creating a custom field.
1. Create the Event-based Action
Log into your instance as an administrator.
Click on the Settings icon in the upper right corner.
Select Apps.
In the left-hand panel under JIRA MISC WORKFLOW EXTENSIONS, click Event-based actions and click Create new action in the upper right corner.
Give your Event-based action a name and, optionally, a description.
Under WHEN, make sure Select Event is selected. In the right-hand panel, select Issue Updated (Figure 1, pictured right).
Set the other options under WHEN as needed.
Under IF SCOPE:
Leave Projects set to Any.
Leave Issue Types set to Any.
Check the box for Only apply to issues that match a Nunjucks condition.
Click the Nunjucks text field and enter the following (Point 1, Figure 2, right):
You MUST update the script below - the<your field id>
placeholder - with the field ID of your Escalated field (see Configure the Nunjucks Script, below).{% if (not context.changelog.fields["<your field id>"].from.length) and (context.changelog.fields["<your field id>"].to_string == "True" ) %} true {% else %} false {% endif %}
Click Save (Point 2, Figure 2, right)
Configure the Nunjucks Script
The Nunjucks script in Step 8, above, will test if both of these conditions are true at the time the issue is updated:
The original value of Escalated was empty AND
The updated value of Escalated is
True
.
In other words, among the edits that occurred to trigger the event, the Escalated field was set to True
. If the value is already True
and other edits occur or the edits do not include the Escalated field, the Event will not trigger.
You MUST update the <your field id>
placeholder in the script above with the field ID of your Escalated field. To do this:
Click the Issue Fields help tab along the bottom of the script editor.
Select Escalated from the Select a field pulldown menu.
Take note of the custom field ID displayed in the examples (Figure 3, right). In this example, the field ID is
customfield_10071
.Enter your custom field ID in the script, replacing
<your field id>
.
2. Add the Assign issue(s) post function
Under THEN, click Select Post-functions.
In the right-hand panel, click Assign issue(s) in the list of post functions. The Assign issue(s) post-function configuration screen will open.
For Target issues leave the default value of Current Issue.
For Assign to select Project Lead.
Leave Assignment behavior as the default value of Always.
Configure the remaining options as needed.
Click Save.
3. Add the Transition issue(s) post function
It is recommended that you use the transition ID when selecting transitions; if the selected transition(s) are renamed in your workflow, this post function will fail until you update the post function!
Under THEN, click Select Post-functions if it is not already selected.
Click Add Post-function in the upper-right corner of the right-hand panel.
Select Transition issue(s) and click Add. The Transition issue(s) post-function configuration screen will open.
Leave Target issues as Current Issue.
Click the Transition Picker button to select a Transition.
In the Pick a transition window:
Select your workflow from the Workflow name pulldown menu.
Select the transition for moving issues into the In Progress status (e.g. Begun Development in Figure 5, right).
Click Use transition ID.
Configure the remaining options as needed. See Transition issue(s) for more information on this post function.
Click Save.
Save and Test the Action
In the main Event-based Action editor, click Save to complete the configuration. To test the new action, create a new issue but leave it unassigned and in your Backlog. Then edit it to set the Escalate field to ‘True’. Verify that JMWE assigns the issue to your Project Lead and moves the issue to In Progress.