Conditions within the "If block" used in the Automation Rule
Asked by vincenzo_spatafora:

Dear ALL,

in the Jira Automation Rule, given an "If block", is it possible to add more than one conditions?

I have added 2 conditions (which I know for sure they are both true) but the If block is NOT executed.

See please the attached screen-shot.

Do I do somthing wrong or this is a known limitation of Jira DC?

Is there by chance any workaround?

Thanks in advance,

Vincenzo.

![If_block.PNG](/t5/image/serverpage/image-id/323820i6D5DF2132F17FAE0/image-size/large?v=v2&px=999 "If_block.PNG")


Answers:
author: Bill Sheboy
body: Hi [@vincenzo_spatafora](/t5/user/viewprofilepage/user-id/5485027)

Without seeing your entire rule or audit log details, it is difficult to diagnose this. Please post images of both of those. Thanks!

Until we see those...

How do you know both of those conditions are true? Did you try writing the values to the audit log to confirm the values before the conditions?

And...smart value lists use 0-based indexing:

* the first item is found with get(0)
* the next with get(1)
* ...

Your {{issue.subtasks.get(2).status.name}} is comparing to the *third subtask*. Is that what you expected?

Kind regards,  
Bill

comments: author: vincenzo_spatafora
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313),

that's correct: I know the 2 conditions are true because I print them in the audit log.

See please the details attached.

Yes, get(2) is comparing to the third sub-task, that's what I need in my rule.

It seems to me that really the "If block" doesn't work there are more than 1 condition.

Thanks in advance,

Vincenzo.![If_block_Audit_Log.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/324166i0506AAF899D764CD/image-size/large?v=v2&px=999 "If_block_Audit_Log.PNG")


author: Bill Sheboy
body: Please note {{issue.subtasks.get(2).status.name}} contains "Closed" and you are comparing to "CLOSED", and so the comparisons do not match as they are case-sensitive.

You could either change the condition case to match, or better still, force the smart value to a known case by adding toUpperCase() at the end:

<https://confluence.atlassian.com/automation/jira-smart-values-text-fields-993924863.html#Jirasmartvaluestextfields-toUpperCasetoUpperCase()>


author: vincenzo_spatafora
body: Thank you very much [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313), I should have thought about that.

What about the case when the sub-task has been re-opened, I mean, what would it be the syntax to use in the "Second value"; see please the attached screen-shot:

![if_block_second_value.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/324197iD32E905E1B4BB622/image-size/large?v=v2&px=999 "if_block_second_value.PNG")

which I have tried out but it didn't work.

Thanks, Vincenzo.


author: Bill Sheboy
body: When trying to match this way, the exact case must be used. Please look at example issues and your status configurations to match the names.

Again as an alternative, you could force the names to uppercase for comparisons:

{{issue.subtasks.get(2).status.name.toUpperCase()}}


author: vincenzo_spatafora
body: Thanks [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313).

Ok but then, how can I implement the "OR" condition within the If block?

So, the sub-task status name can be either Reopened OR Open.

Thanks for your help.

Kind Regards, Vincenzo.


author: Bill Sheboy
body: You could use separate conditions in the if / else block for each status name, or use a single logical expression with the OR operator: <https://confluence.atlassian.com/automation/jira-smart-values-conditional-logic-1081351607.html>


author: vincenzo_spatafora
body: Thank You [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

I was not aware of that syntax, working now.

Thanks a lot,

Vincenzo.


Tags: data-center

jira

jira-data-center