Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Conditions within the "If block" used in the Automation Rule

vincenzo.spatafora
Contributor
May 15, 2024

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

1 answer

1 accepted

0 votes
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 15, 2024

Hi @vincenzo.spatafora 

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

vincenzo.spatafora
Contributor
May 16, 2024

Hi @Bill Sheboy,

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 

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 16, 2024

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()

vincenzo.spatafora
Contributor
May 16, 2024

Thank you very much @Bill Sheboy, 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

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

Thanks, Vincenzo.

 

 

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 16, 2024

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()}} 

vincenzo.spatafora
Contributor
May 17, 2024

Thanks @Bill Sheboy.

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. 

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 17, 2024

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

vincenzo.spatafora
Contributor
May 27, 2024

Thank You @Bill Sheboy

I was not aware of that syntax, working now.

Thanks a lot,

Vincenzo.

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events