Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

automation - Advanced compare "or" condition??

Jack Brickey
Community Champion
September 24, 2021

Calling all automation gurus...

So I'm building an automation using the advanced compare condition to perform a pattern match on the last comment. Basically I want to transition an issue to in progress if the last comment contains any of a certain number of words. However at the advance compare condition seems to only have the "all match" capability. As shown below ideally I could choose if any match. I know I can do if/else block but that seems so inefficient.

ugh.... will load image later. The community app does not like safari and won't allow me to load an image. Driving me crazy. :(

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.
September 24, 2021

Hi @Jack Brickey 

How about an advanced compare condition using a regular expression?

  • first value: {{issue.comments.last.body.match("(foo|bar|hello)")}}
  • condition: does not equal
  • second value: leave it empty

You will need to refine that expression if you want whole words only, case-sensitive, etc.

Kind regards,
Bill

Jack Brickey
Community Champion
September 24, 2021

thanks Bill!

so here is what i currently have

2021-09-24_14-20-54.jpg

so applying your guidance I would use the following...

2021-09-24_14-33-20.jpg

but not sure I get the use of "does not equal" and "empty". I think I am misunderstanding here.

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.
September 24, 2021

That match() function will return any matches found for the regular expression.  If any of them are found, the result "does not equal" empty...so proceed with processing.  I tested this way and it seems to work.

I believe another way to do this is invert it, and put a regular expression in the second value and try for a match rather than no-match.

Like # people like this
Jack Brickey
Community Champion
September 24, 2021

Cool! I will give it a go.

cheers

Like # people like this
0 votes
Mykenna Cepek
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.
March 31, 2025

Late to the party, but...

OPTION 1:  Some OR conditional functionality is built-in to some conditionals. Example: "is one of" option in the "Issue fields condition". That can check, for example, if the Assignee is Mary or Bob.

OPTION 2:  When there is no built-in support, the smart value or() function provides a messy but functional alternative:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#or

Sample use case:  A rule triggers on a new Comment added to an issue, and I want to proceed only if it was Mary or Bob who added the comment. The "Issue fields condition" doesn't provide access to the comment author (it's not a standard or custom field for an issue).

So I'll use a "Smart values condition" instead: 

SmartValueOR.png

It's a bit brittle, as the user name is in text form (whereas the OPTION 1 approach above relies on user ID values internally).

You could check against just comment.author if you knew the user ID value, but that would make your rule much less readable -- my Cloud user ID is 43 characters of nonsense.

Mykenna Cepek
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.
April 7, 2025

Also, the "If/then/else" conditional in Jira Cloud now has an option for AND vs OR with the configured conditions:

IfConditionOrOption.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events