cancel
Showing results for
Did you mean:
See all
##### Top groups
Explore all groups

# If condition doesn't work as expected

Iana January 26, 2022

I have an automation rule with embeded "If-else" conditions within "If" conditions.

I expect the "if-else "conditions to be exclusive (if one is met, then the rest is not evaluated).

I expect the "If" conditions to be inclusive (even if the first "if" is met, the rest of the "If" is evaluated). Likewise, when the first "If" is not met, then the second "If" should be evaluated.

Below the image of most of my rule. When the rule is executed, it evaluates the first "if "(red arrow) and if it is met, it evaluates the "if-else". However it never actually gets to evaluate the second "if" (2nd red arrow).

Any ideas why?

#### 1 accepted

1 vote
Mykenna Cepek
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2022

The original post said:

I have an automation rule with embeded "If-else" conditions within "If" conditions.

Actually, the rule you posted has a series of IF and IF-ELSE conditions. No conditions are "embedded" or nested. Jira Automation, to my knowledge, cannot nest conditions (although conditions may be used inside a branch).

Your rule is a linear series of steps. Regarding conditions:

• IF A THEN B ELSE C will execute either B or C, and then always continue after the condition.
• A simple IF will terminate the rule if the condition(s) it evaluates is false.

Hope that helps!

Iana January 27, 2022

I tried using the brach, but it won't allow if-else conditions.
I need a rule with 2 levels of if-else conditions.

Is there any way to achieve that with automation?

Something like this:

If Field_1 is A then
change_1.a
If Field_1.1 is A.1 then
change_1.a1
else if Field_1.1 is A.2 then
change_1.a2
else
change_1.a3
else if Field_1 is B then
change_1.b
If Field_1.1 is B.1 then
change_1.b1
else if Field_1.1 is B.2 then
change_1.b2
else
change_1.b3

Mykenna Cepek
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2022

Yes, you can achieve this in automation another way. (This is where my 20+ years as a software developer comes in handy...)

You can replace nested IF-THEN-ELSE conditions with a single IF-THEN-ELSE by adjusting the conditions appropriately. I've converted what you posted above to illustrate how to do that:

If (Field_1 is A) and (Field_1.1 is A.1) then
change_1.a1
else if (Field_1 is A) and (Field_1.1 is A.2) then
change_1.a2
else if (Field_1 is A) and (Field_1.1 is not A.1) and (Field_1.1 is not A.2) then
change_1.a
else if (Field_1 is B) and (Field_1.1 is B.1) then
change_1.b1
else if (Field_1 is B) and (Field_1.1 is B.2) then
change_1.b2
else if (Field_1 is B) and (Field_1.1 is not B.1) and (Field_1.1 is not B.2) then
change_1.b

1 vote
Manon Soubies-Camy _Modus Create_
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2022

Hi @Iana,

Automation is designed so that, if a condition fails, no actions following it will be performed. The "if/else" condition is actually an exception: if a condition fails, then we go to the next "else", then to the next one, and so on.

Hope this helps!

- Manon

Iana January 27, 2022

Thanks for clearing that out Manon!

Pramodh M
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2022

The second will not be evaluated, that is how it works

Pramodh M
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2022

If any condition fails Automation will stop at that point!! Better use branching to separate the checks here for your requirement

Iana likes this
Iana January 27, 2022

Thanks for your reply. Do you have an idea on how I could have 2 levels of if-else conditions using the branching?