Automation - multiple if condition in lookupissue

Andrii Mykhailytsia
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!
May 25, 2023

Hi, 

Are there a way to use multiple if conditions inside one lookupissue block?

I want to have priority as a slack emoji so I tried this:

{{#lookupIssues}}
<{{url}}|{{key}}> {{#if (equals issue.priority.name, "P0 - Blocker")}}:p-blocker: {{/}}{{#if (equals issue.priority.name, "P1 - Critical")}}:p-critical:{{/}}{{#if (equals issue.priority.name, "P2 - Major")}} :p-major:{{/}}{{#if (equals issue.priority.name, "P3 - Minor")}}:p-minor:{{/}} {{assignee.displayName}}: {{summary}}
{{/}}

But it doesn't work, priority is missing in a message.

Are there any way to do this?

2 answers

1 accepted

1 vote
Answer accepted
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.
May 25, 2023

Hi @Andrii Mykhailytsia -- Welcome to the Atlassian Community!

I see two problems in your expression:

  1. Inside of a Lookup Issues iterator, you use an {{issue. prefix for the fields, but that is not needed as the fields are part of the lookup instead.  Try removing those.
  2. Your calls to the equals() function were missing their parentheses.

Perhaps try this one:

{{#lookupIssues}}
<{{url}}|{{key}}> {{#if(equals(priority.name,"P0 - Blocker"))}}:p-blocker: {{/}}{{#if(equals(priority.name,"P1 - Critical"))}}:p-critical:{{/}}{{#if(equals(priority.name,"P2 - Major"))}}:p-major:{{/}}{{#if(equals(priority.name,"P3 - Minor"))}}:p-minor:{{/}} {{assignee.displayName}}: {{summary}}
{{/}}

I may have adjusted your spacing, so please fix that as needed.

By the way...you might also try the new Lookup Table feature to do this without conditional logic: https://community.atlassian.com/t5/Automation-articles/New-Automation-action-Create-lookup-table/ba-p/2311333

Kind regards,
Bill

Andrii Mykhailytsia
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!
May 26, 2023

@Bill Sheboy it works, many thanks!

0 votes
Dan Breyen
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.
May 25, 2023

Hi @Andrii Mykhailytsia welcome to the Community!  YES, I have one Automation that takes the User submitted Impact and Urgency in JSM and transforms it into a Priority.  It's checking 4 different Urgency values against 4 different Impact values.  Granted some of the values are the same but it starts with IF... and then continues with 10 different ELSE IF statements.  Support helped me out with it, but we got it to work. I would try it out in an Automation, there are even some KBs out there to help out.  If you need assistance, I'd give Support a shout.

Suggest an answer

Log in or Sign up to answer