Multiple IF statements that are not mutually exclusive

Ivo_de_Vries November 11, 2019

Hi,

I have created a checkbox customfield where multiple options can be selected. I have tried to create an automation rule that checks for each options if it is selected, and if so creates a specific issue (see below). 

Now In the below example, if I select both 'UK' and 'ES' cultures, both issues are created. But if I only select the second option (ES), nothing happens as the automation does not get past the first validation. It must be because these IF statements are actually nested and not validated separately. If it doesn't pass the first IF, the second is never reached. This forces me to create separate automation rules per culture. Is there anything that I can do to perform this automation in a single rule?

Mutliple IF statements.png

2 answers

1 accepted

22 votes
Answer accepted
David VanDyke August 21, 2020

Hi, @Ivo_de_Vries -

I just encountered a similar issue while working for a customer.  My co-workers and I figured out that if you embed each separate If statement in a Branch, they will all be validated separately.  Here's what we came up with:

Multiple_Ifs.JPG

I hope that helps you (belatedly).

Dan Checovetes September 3, 2020

This is perfect!  This worked for me, and I believe this would help the OP in the situation they were having.  This solution should be at the top.

mohnage7 January 26, 2021

Thanks @David VanDyke that helped me

John Young October 28, 2021

Fantastic!  This has been annoying me for hours.  It's so annoying that when an IF is true it ignores all the others :/

Robert June 23, 2023

helped, thanks!

John Young June 23, 2023

Thank you also!!!  Works fine for me. Wish there was a better way though, or a simple scripting language (would be quicker to write more complicated checks)

Kawtar Amajoud
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!
March 21, 2024

In this case all branches run simultaneously. Is there a way to have them run one by one?

 

In for example the next use case: if it passes some condition > field A is fetched and some data is appended to this field. Same thing for the next branches.
Due to all the branches running simultaneously though, it is not possible to have multiple additions.

0 votes
Deleted user November 12, 2019

Hi Ivo,

I'm Ilenice, from Automation for JIRA Support team.

Thanks for your question!

Well, what is happening to your rule is that, since “ES” option is selected, the first JQL condition doesn’t match, and then the rule stops executing, not even checking the next condition.

To your use case, I would suggest you use an IF/ELSE block condition:

IfElseCondition.png

You can configure your two JQL conditions inside this IF/ELSE block condition. I’ll show you how.

Please set your rule using the structure described below:

  • TRIGGER - When issue transitioned;
  • CONDITION: IF/ELSE BLOCK
    1. IF BLOCK
      • JQL Condition, setting the expression issuetype = "Communication Request" AND "Type of Communication" = "Urgent communication" AND Cultures = UK
      • CREATE ISSUE action
    2. ELSE BLOCK
      • JQL Condition, setting the expression issuetype = "Communication Request" AND "Type of Communication" = "Urgent communication" AND Cultures = ES
      • CREATE ISSUE action

It’ll look like the following:

18725_ExampleRule.png

 

So, please note that when using an IF/ELSE block condition, if the first condition doesn’t match, Automation will check the next condition. :)

I hope it helps!

Let me know if there is anything else I can help with.

Cheers,

Ilenice

Ivo_de_Vries November 12, 2019

Hi Ilenice,

Thanks for your elaborate and quick answer. This also is not a solution for the current use case as the IFs are not mutually exclusive, I will explain a bit more on the context and the current (not ideal) workaround I have for it.

Our company serves about 18 countries and whenever we send out a communication, an issue of this type is created first. Whilst creating the issue, the cultures are selected that the communication applies to. Per culture that is selected, I want to generate a ticket for that specific department to handle the translation and sending of the communication. On the creation screen, the reporter also selects one of the predefined 'e-mail templates'. 

Ideally, I would like to create a single automation rule per e-mail template, with an IF for every culture. IF checkbox culture is selected for UK, ES, NL and FR, the automation rule should create 4 issues respectively for each country. Using multiple IF's or an IF/Else structure does currently not work as explained above. 

I would like to have a single automation rule per e-mail template as it is much more efficient to copy a rule for a new template (with all the IFs per culture) each time we introduce a new one (and make small adjustments to it). Currently my workaround is not to create automation rules per template but per culture (18 rules). Every time a new template will be added, I will have to add another IF statement to each of the 18 rules.

Deleted user November 14, 2019

Hi Ivo,

thanks for replying and I’m sorry for my late response.

I’ve discussed this point with the dev team and, unfortunately, at the moment it’s not possible to achieve the result you want at the moment. For now, it indeed demands you to configure the 18 conditions, that is, one condition to each country available on the checkbox field. 

However, through AUT-81 https://codebarrel.atlassian.net/browse/AUT-81 (You may need to open in an incognito window) we’ve been tracking an improvement which could help you on this, so we might have good news in the future. :)

In case you have any other questions or doubts, please feel free to make a new contact.

Cheers,

Ilenice

Like Ivo_de_Vries likes this
Deleted user December 3, 2019

Hello

Do you know why i cant see if-else block while adding new component condition in Branch rule in second screen shot with red pen?

thanks
Milan


sc-1 with if-else block.PNGsc-1 without if-else block.PNG

Deleted user December 4, 2019

Hi, @[deleted]!

Yes, you're right, this is indeed not available. :(

By now, it was restricted to prevent performance issues.

There's an AUT raised for this, through which this point is being tracked: https://codebarrel.atlassian.net/browse/AUT-1005 - you might need to open this on incognito.

Let me know if there is anything else I can help with.

Cheers,

Ilenice

Like Deleted user likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events