Let us say I have a multi-select field that has values A, B, and C.
If the field contains A, then execute actions 1, 2, and 3.
If the field contains B, then execute actions 4, 5, and 6.
If the field contains C, then execute action 7, 8, and 9.
The actions may or may not be the same for each field value. For two of the value the actions may be Assignee and Send Email while for another value the actions may be Edit Work Item and Comment on Work item (for example).
When the field contains multiple values the actions associated with each value need to be executed. So if the field contains A and C, then execute actions 1, 2, 3, 7, 8, and 9
This can't be done with a series of If blocks since the rule will terminate on the first IF that doesn't evaluate as TRUE.
It can't be done with IF/ELSE statement because the actions for only the first matching value will execute.
There are too many values for the field to try to do all permutations of combinations of values.
Does anybody have a suggestion for a solution for this?
Hey Trudy,
How many options are we talking about?
In cases like that I have used multiple branches with each branch processing for that action but not preventing subsequent branches from processing. Once you do the first branch and all of the actions/conditions under it, then you can copy the branch which will copy all of the actions and then just change out what is different.
Hello @John Funk
Right now there are individual automation rules for 11 values:
Rule 1:
if field contains A do these actions.
Rule 2:
If field contains B do these actions
etc.
Can you provide an example of how you would do multiple branches? What would be the condition for your branches?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you mean something like this?
WHEN triggered
BRANCH: JQL: key={{triggerIssue.key}} and Field is in (A)
DO THINGS
BRANCH: JQL: key={{triggerIssue.key}} and Field is in (B)
DO THINGS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The above does not work because Branch JQL automatically excludes the trigger issue from being considered in the results set. Even if I add
key={{triggerIssue.key}}
the branch says no matching related issues are found.
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.
Hi @Trudy P Claspill
Thanks for the interesting question :)
One approach that comes to mind is to use multiple independent IF blocks rather than nesting them as If/Else.
Each IF condition will be evaluated independently, so if the field contains both A and C, the rule will execute Actions 1, 2, 3, and, via the next block, Actions 7, 8, 9.
The rule won't stop after the first matching condition because these are separate If blocks rather than an If/Else structure.
I will also be happy to read another interesting solutions :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Gor Greyan
Thank you for your reply, but you are incorrect.
A rule will exit when an IF condition evaluates as false.
Let us say my field has options: All, French, German, Spanish.
Let us say I set the field in an issue to select All, French, and German; not Spanish.
Let us say I have a manually triggered rule with this structure:
If Spanish then comment Spanish
If French then comment French
If German, then comment German
When I run that rule it stops running at the "If Spanish" block because that condition is not met.
I have found a partial solution for the case when the same action should be taken for each value such as the case above where the action is to add a custom Comment for each value.
In that case I can iterate over the values in the field with an Advanced Branch, and use a Lookup Table to look up the field value and get the custom comment text to use in the Comment action.
I haven't yet figured out how to handle a need for different actions based on each value in the multi-select field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you.
Yes, it is right, my original suggestion wasn't correct. I was approaching it from a different angle and expected the conditions to be evaluated independently. In Data Center, I have automations in that logic, and it is not stopping after the first IF, when it is false.
It's an interesting use case, and I'm going to give it some more thought to see if I can come up with another solution that keeps everything within a single rule. If I find one, I'll be sure to come back and share it here.
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.