Need to create Automation to email a specific group of users depending on Custom Field Value.

Gabriel Greenbank
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 5, 2023

I have several Email Groups that I need to send emails out based of off a Custom field value: {{MOP - Group}}

 

This field is set up as a short list. example values are

IPA, IPR, Transport, Etc.

I want to when the issue is transitioned to status Under Review

To pull the custom field value {{MOP - Group}} and based off of the value email the group of email addresses that are assigned to that value. 

I have very little programming experience and so even with this little thing which is probably very easy I am having trouble with finding a solution. 

 

Any help would be appreciated.

Thanks,

2 answers

2 accepted

2 votes
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.
July 5, 2023

Hi @Gabriel Greenbank -- Welcome to the Atlassian Community!

Is your list of email address only for this rule or for other uses?

If it is just for this rule, perhaps try a Lookup Table to store the email addresses and then key them to the custom field value.  Please look here for more information on that method: https://community.atlassian.com/t5/Automation-articles/New-Automation-action-Create-lookup-table/ba-p/2311333

To use that in your email you would enter your table name and custom field as the key, such as this:

{{myTableName.get(issue.myCustomField)}}

Please adjust that based on your custom field's type.

Kind regards,
Bill

Arild Hoyland September 14, 2023

Hi Bill,

have you tested this for 'send email action'?

I gave this an attempt now - created a lookup variable named "emails", with key "email" and the following value "email1@at.com; email2@at.com". But when I tried to run my rule the automation failed, claiming that bcc-field in 'send email action' was empty.

 

When I changed my lookup entry to only contain "email1@at.com" the rule succeeded. So I'm assuming this is due to the fact that the bcc-field (and to-field I guess) in 'send email action' doesn't support semi-colon or other separators in between multiple email adresses.

But not sure if I should've tried another way of referencing the lookup variable in the 'send email action':

Jira auto email-to.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.
September 14, 2023

Hi @Arild Hoyland 

My hypothesis is the BCC field is not recognizing the separate email address, instead only seeing them as a single text value.

Let's try splitting to create a list of values.  Assuming your delimiter is "; " then please try this:

{{emails.get("email").split("; ")}}

Please adjust accordingly for your delimiter between the email addresses.

And also...For things like variables and tables in rules, I recommend using a unique naming convention to avoid the risk of matching other smart values.  For example, prefix your variable names like this with varMyVariable and the lookup tables with tblMyLookupTable.

Kind regards,
Bill

Like # people like this
Arild Hoyland September 15, 2023

To the rescue as always! This worked perfectly, thanks Bill!

Like Bill Sheboy likes this
Julian Governale
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.
October 18, 2024

The split function worked perfectly in my scenario too!  I feel like half the rules I have built I need to somehow give @Bill Sheboy credit as he always seems to have the missing function I need to get my rules to work correctly. 

1 vote
Answer accepted
Alisa Zamaraeva
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.
July 5, 2023

Hi @Gabriel Greenbank 

The easiest way is to create an automation rule with this items:

1. Trigger - Issue transitioned (there you can choose statuses 'from' and 'to' or leave empty for every issue transition).

2. Condition If-Else with issue field condition based on your custom field value.

3. Action Send email. If condition is met, the rule will send an email to address you choose. You can send email to multiple addresses at the same time. If recipients of these emails are added to your jira instance, you can create jira groups and send email to a jira group. All members of jira group will receive an email.

As result your rule will be similar to what you can see on the picture below:

Screenshot from 2023-07-05 22-16-57.png

Hope this helps!

Gabriel Greenbank
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 7, 2023

Thanks! This is the solution I used and it is exactly what I needed. I think that using a Lookup table might have worked as well, But I think that this solution was easier to get my head around. 
Thanks,

Suggest an answer

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

Atlassian Community Events