Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation rule to set different priority based on different values in the description fields

Raul Blazquez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 22, 2022

I am trying to define an automation rule based on Smart Values that sets the priority of an issue based on finding in the issue description the value of a severity. The issue is originated via mail from a different ticketing system.

The logic would be something like:

- If summary contains "Severity" and after Severity I find:

  • "Low" then priority is P4
  • "High" then priority is P2
  • "Critical" then priority is P1

By default, tickets are P3.

I have tried different approaches, none of them seem to work:

- Branching, which seems to work, but after branching setting the priority I need to clone the ticket into another project and carry over the priority, and in some cases it hasn't been updated in time, which clones the ticket with incorrect priority

- IF/THEN actions, which could work but would force me to copy all actions in the 4 different branches, which does not sound right to me

- Smart values like this work in an EDIT field action:

{
"fields": {
"priority": {
"name": {{#if(issue.description.substringAfter("Severity").substring(1,50).match(".*(Critical).*").isNotEmpty())}}"P1"{{/}}
}
}
}

However, I can't use them to set different cases as per my logic, and If I try to duplicate the edit action as per my conditions, it retrieves the error invalid JSON, I suppose because it does not accept different values for the same field even when there is an #if

Any recommended approach for this? 

2 answers

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 23, 2022

Hi @Raul Blazquez 

First thing: I recommend using a select list field for your values rather than the Description to drive setting the Priority.  It is more manageable, controllable for entry, and reduces errors.

If that is not possible, I recommend using the last approach with conditional logic, with some adjustments.  The reason you got the invalid JSON is that you are not handling all possible cases.

I recommend...

  • first, before updating the rule confirm the exact syntax to expect for the Description field
  • using an if/else, add a single condition with a regular expression to confirm the Severity is one of your expected values
    • and if so, you can extract the value into a created variable...
    • using that with the conditional logic in the JSON expression
  • for the else to the condition, set the default value to P3

You could do all of this in a single condition, with nested ifs, although that will be more difficult to debug and maintain over time.

Kind regards,
Bill

0 votes
Gaurav
Community Champion
December 23, 2022

Hello @Raul Blazquez 

As per my understanding, IF/ELSE construct is the best way.

For this, you can extract the substring, store it in a variable and use it to build the If/ELSE construct.

Please let me know if you ned help with the rule.

--GG

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events