Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I send an email to only some Request participants via Automation for Jira?

Paul Benati
Contributor
May 20, 2020

All,

I'm looking for a way to iterate over the Request participants field within a JSD issue and if the email domain is not "companyname.com", then send that participant an email.

For example, if the Request participants field contains:

  1. john.doe@company1.com
  2. jane.doe@company1.com
  3. roger.rabbit@supportcompany.net
  4. jessica.rabbit@supportcompany.net

How do I send an email to only the Request participants with an email domain of "company1.com" via Automation for Jira?

Note:  don't worry about the trigger event for the automation and/or just assume "When:  Issue commented"

Thanks,
Paul

2 answers

1 accepted

2 votes
Answer accepted
Paul Benati
Contributor
May 28, 2020

All,

For those looking for how I solved this, then here it is.  I leveraged Automation for Jira (now baked into Jira) and used the following smart-value for the email's To: field...

 

{{#issue.Request participants}}{{emailAddress.replaceAll("(.*supportcompany.*)","")}},{{/}}

 

The above smart-value will essentially remove all email addresses containing the "supportcompany.net" string from the To: field.

 

Note:  my original request was how to only send emails to a specific email domain, but in actuality, I need to send emails to all email domains sans a specific one.  The above solves this requirement for me.

-Paul

0 votes
Cody Stevens
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.
May 20, 2020

Hey @Paul Benati 

Something  like Scriptrunner may be better for a situation like this but here's what I think you can do in AFJ.

 

I"m assuming that the list of participants you want to email are a standard group. If I am wrong and this list is not the same group of people, you probably cant use this solution.

 

You can set up an IF Statement to check the "Requested Participants" field. You would select a single user from the people you want to notify because this is only checking to see if that one user is in the list. If they are it will then send an email to them. Then you would set up a branch to run a new set of conditions and actions. This would then check the same issue for the next person. Repeat this as many times as necessary.

 

Here is a picture of an example I made. I did it this way because as far as I know, you cant pull the list of participants and dynamically send emails to only certain people.

Screen Shot 2020-05-20 at 12.25.09 PM.png

Paul Benati
Contributor
May 20, 2020

Cody,

Thanks for your reply.  I don't think this will work as I don't know how many people are in the Request participants field ahead of time.  I was hoping there's some mechanism to do something like:

If: all match

image.pngthen

{{#issue.Request participants}}{{emailAddress}}
if(emailAddress.substringAfter("@")="company1.com", then sendEmail(to:emailAddress;subject:"blah";body="blah, blah")
{{/}}
Like Marek Kaszuba likes this

Suggest an answer

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

Atlassian Community Events