Would it be possible to setup an automation rule for sending an email to an unique email address for each option(s) selected randomly in a multi-select choice custom field in Jira DC?
I have a multi-select choice field "tags" with 10 option values in a Story issue type. Now whenever user makes a selection either one value or multiple values then Automation should send out an email accordingly.
Custom field name: Tags
Options: A, B, C, D, E, F, G, H, I, and J
Corresponding Emails: Option A -> A1@gmail.com, Option B -> B2@gmail.com, Option C-> C3@gmail.com, Option D -> D4@gmail.com, Option E -> E5@gmail.com, Option F -> F6@gmail.com, Option G -> G7@gmail.com, Option H -> H8@gmail.com, Option I -> I9@gmail.com and Option J -> J10@gmail.com
My current automation rule is not working as expected.
Trigger: Field Value changed
If Condition: tags equals A then send email to A1@gmail.com
Else if: tags equal B then send email to B2@gmail.com
and so on till Else if: tags equal J then send email to J10@gmail.com
This automation rule works only for a single selection in tags field and if I select more than one value then this rule fails obviously. Now rather listing all combinations and permutations inside this if condition loop, would it be possible for automation rule to send all corresponding emails for any number of options selected inside the tags field randomly?
Hi @VVC
First, here are some questions to clarify the scenario you are trying to implement:
How many different email body contents are there: one to send to everyone or a different one for each recipient?
When do you want to send the emails? That is, every time the field changes send an email to each selected recipient, or something else?
What does the "random selections made" mean? Do you mean any values could be selected, or that there is some actual randomizing happening?
Until we know the answers to those questions...
With the if / else block in rules, one-and-only-one of the choices is selected. It does not process each entry which meets the criteria.
Jira Data Center's version of automation does not support the Lookup Table or Advanced Branch features yet. Thus your workaround options depend on the answers to the questions above. A couple of options are:
Kind regards,
Bill
Thanks @Bill Sheboy for asking these questions and see below for my response. Please let me know if this helps further to draw a concrete solution.
How many different email body contents are there: one to send to everyone or a different one for each recipient?
VVC: About 7 option values has same email body contents, while the remaining 3 option values have different and unique email body contents. Each recipient is different, so each one has unique email address. In other words, 7 recipients has same email body contents, while the remaining 3 recipients has different email body contents.
When do you want to send the emails? That is, every time the field changes send an email to each selected recipient, or something else?
VVC: Email(s) should be sent out to each unique recipient as soon as the field value changes in the ticket.
What does the "random selections made" mean? Do you mean any values could be selected, or that there is some actual randomizing happening?
VVC: Any value or multiple values could be selected randomly based on the internal business process on this multi-select choice custom field called tags.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Based on your answers, the rule could use first approach I described with branching. For example:
As I noted earlier, this would send an email to each selected value's recipient every time the rule runs. If you instead only want to send the email once, some indicator must be saved (such as with another field) to detect the email was already sent.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bill, I have been trying few different ways to get this working and if I remember correctly, the condition field contains "value A" works which sends the email once. But when selecting multiple values randomly either during the ticket creation or ticket update operation, the emails to the individual recipients doesn't work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The trigger for field value changes only fires when an issue is updated. When you want the emails for Issue Created also, the rule will need to be duplicated to use that trigger.
For an issue update which does not send the correct emails, you would need to research that for each case to determine the cause. Note that if you leave the field when selecting the values, that will trigger the rule each time the field changes.
And once again, without seeing images of your complete rule and the audit log details, these are just guesses. I recommend trying what is described above to learn what helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The if, else condition with Advance compare two values seems like a good fit so far. I would also like to extend the automation to stop sending email if a pre-existing option is unselected at any point. Is there a way to stop the notification, if an existing option is unselected?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wouldn't that take care of itself? That is: when the value is not selected that email would not be sent.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When A, B & C option values are selected in a tag (multi-select) field then an email goes out to the respective email address. Let's say that you edit the ticket and unselect the existing C option value then email goes out to respective email address for A & B options.
Any ideas or suggestions to tweak my automation rule to stop sending emails when an existing selected option value is unselected?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes: do not use the change log and instead please test each case as I noted earlier.
Thus if a value is not selected it will not be found in the Tags and the email will not be sent. However, this rule will also send all found value emails each time the rule runs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bill, I have already tried your suggested automation rule but it still doesn't work as expected. Instead, this logic does send a repeated email for existing selected tag options besides an email for the new selected option.
When deselecting existing option(s), an email goes out for the remaining tag option(s) owners. I have also tried adding Advance compare condition along with Re-fetch issue data action but still no luck at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let's pause to confirm your scenario: do you want to send emails only for the added Tags?
In that case, the rule can only be done if you have the Create Variable action in your Server / Data Center version (or with Jira Cloud). Do you have that in your version of automation rules?
If so, let's first create a test rule, using the change log and a regular expression to try to identify the added Tags.
{{#changelog.Tags}}{{fromString}}{{/}}
{{varFromString.split(" ").join(",")}}
{{issue.Tags.value.join(",")}}
{{#if(varPreviousTags.length().gt(0))}}^((?!({{varPreviousTags.split(",").join("|")}})).*){{/}}{{#if(varPreviousTags.length().lte(0))}}(.*){{/}}
{{varCurrentTags.split(",").match(varRegularExpression)}}
Now test the rule, adding and removing values for the Tags field on an example issue. Review the audit log after each test. If the varAddedTags contains only the added ones, it can then be used with the earlier conditions to test and send the emails.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
With your Variables logic, the audit log for each test is capturing the added or removed values for the Tags field. I have never used the Create Variable action logic in the past, so could you please help by showing me one example of how I can actually use it with the earlier conditions for a quick reference please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is great news!
Now that we have the {{varAddedTags}} smart value with a list of Tags, such as:
A, B, C
You may use the Advanced Compare Condition to test if it contains one of the values needed. This would replace the Issue Fields Condition you used earlier.
I recommend trying just one first to confirm it works as expected before adding the others.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill, I was OOO and now back onto this one. Unfortunately, the end result was same as the automation rule still send an email when an existing pre-selected option is deselected, which is NOT desired at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you review the audit log, how many times is the rule triggering when you change the field: one time or multiple times?
If it is multiple times, have you confirm you are not exiting the field and so making it an edit for each change?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One of the challenges of re-building something that should already work in rules is our workarounds tend to be "brittle" and challenging to test. Oh well...let's try again :^)
Please see my earlier post as I recreated the variables to handle the different cases, and account for the possibility a changelog's {{fromString}} is delimited by spaces and not commas.
Again, I tested this with Jira Cloud and so the regular expressions may be different for Server / Data Center automation. Here are the cases I tried:
Please add multiple cases to match your scenario.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Bill for your continued support assistance. Initially it looked like working but upon throwing multiple scenarios then it kept failing and inconsistent results. I will run a few more tests today and see how this works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy You're the STAR. A few minor tweaks to your logic helped this automation to work exactly as needed. THANK YOU SO MUCH!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am glad to hear that helped, although I wonder...
From what you show above ^^^ in the last post, the created variable {{varAddedTags}} is referenced but is not defined. Do you still have steps in the rule to create that variable?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great, and just to confirm: is this question resolved?
If so, please consider marking this question as "answered" to help others with a similar need find solutions faster. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.