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?
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.