How to test for the existence of a string within each item in a list (such as Component)?

Vincent Parenti January 24, 2025

I want to use Automation to add a Watcher to an issue if the Component field includes an item that contains a certain string.

For example, the Component field may contain the following four items:

Blue Green

Orange Yellow

Red Yellow

Black Brown

I want to test for the existence of "Yellow" being in any one of the items.

I can easily set up a condition to test if "Components contains any of" and choose "Orange Yellow" and "Red Yellow". But that would mean that I would need to update the rule if "Yellow White" became a possible Component item. I'd like to avoid that.

Bonus: if what I'm looking for is possible, how can I also make it case insensitive?

 

1 answer

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.
January 24, 2025

Hi @Vincent Parenti -- Welcome to the Atlassian Community!

For a question like this, context is important for the community to help.  Please post the following:

* an image of your complete automation rule,
* images of any relevant actions / conditions / branches,
* an image of the audit log details showing the rule execution,
* explain what is not working as expected.

Until we see those...

Have you tried using the match() function with a regular expression and inline iteration, first forcing the case of the component names to a known case (e.g., lower case)?  For example, this will return true if one or more with "yellow" is found in the list of results?

{{issue.components.name.toLowerCase().match("(.*yellow.*)").size.gt(0)}}

Kind regards,
Bill

Vincent Parenti January 24, 2025

Thank you Bill. And thank you for the pointers.

Your suggestion worked.

Now I have a follow-up question.

If I'm able to satisfy the first condition (from my original question), I want to add a specific user as a Watcher. But I only want to add them as a Watcher if they do not already exist as a Watcher.

You may say that the extra logic is not needed...no harm adding them as a Watcher if they already exist. But there is subsequent logic that will run, e.g. sending email, that I want to avoid if the user is already a Watcher.

What I have (shown below) is not working as the email continues to fire each time the Component field is edited and the first condition is met.

Screenshot 2025-01-24 163449.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.
January 24, 2025

Please try removing the quotation marks around the email address in the Second Value  condition.

When the First Value in the condition is this {{issue.watchers.emailAddress}} that will produce a comma-separated values list like this, without any quotation marks around the entries:

firstEmailAddress, secondEmailAddress, thirdEmailAddress

 

Vincent Parenti January 24, 2025

You did it again Bill. And when it still wasn't working, I realized that the comparison I was performing (camel-case vs. lower-case) on the email address was the culprit.

The week ends on a good note. My issue resolved and I found a helpful resource in the "Community".

Thank you again!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events