Forums

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

Automation - comment and send email to all users listed in custom People field

Nur Fatin April 21, 2025

Hello,

I have two custom fields “Business System Owner” and “Technology System Owner” in my Jira Team-Managed project. It is a people field (multiple user).

I'm trying to use automation to comment and send emails to all users in both fields when a specific action occurs. The comment portion works, but the sending email failed. My Jira Site Admin has added the two fields at the global level. But the sending of email action still failed after I chose both “Business System Owner” and “Technology System Owner” in the “To:” field in the send email action. The audit log states two types of error:

  1. Unable to send the email as the recipient's email address wasn't provided
  2. There is no value set for the field:
    • customfield_12874, customfield_12876
    • Unable to send the email as the recipient's email address wasn't provided

I also discovered that there are two “Business System Owner” and “Technology System Owner” fields in the fields tab of the project settings.

I have tried to use smart values in the “To:” field, but to no avail. I have tried:

  • {{issue.customfield_11517.emailAddress}}
  • {{issue.customfield_11517}}
  • {{issue.customfield_11516.emailAddress}}
  • {{issue.customfield_11516}}
  • {{issue.customfield_12874.emailAddress}}
  • {{issue.customfield_12874}}
  • {{issue.customfield_12876.emailAddress}}
  • {{issue.customfield_12876}}

The comment section works in tagging / mentioning the users when I used:
{{#issue.customfield_11517}}[~accountId:{{accountId}}] {{/}}{{#issue.customfield_11516}}[~accountId:{{accountId}}] {{/}}

But it doesn’t work when I used the audit log customfield values:{{#issue.customfield_12874}}[~accountId:{{accountId}}] {{/}}{{#issue.customfield_12876}}[~accountId:{{accountId}}] {{/}}

Attached are the rule set up, the field tab showing duplicate fields and audit logs.

Is there a way to do this? Thanks in advance.

Screenshot 2025-04-22 at 11.01.46 AM.pngScreenshot 2025-04-22 at 11.02.07 AM.pngScreenshot 2025-04-22 at 11.02.40 AM.pngScreenshot 2025-04-22 at 11.03.00 AM.pngScreenshot 2025-04-22 at 11.03.11 AM.png

2 answers

1 vote
Akash Singh
Community Champion
April 21, 2025

@Nur Fatin You're were on the right track, since this is a multi-user picker field, directly referencing the email address using {{issue.customfield_11517.emailAddress}} won't work as expected. The field contains an array of user objects, so you'll need to iterate over that array and extract the emailAddress from each user. These email addresses can then be concatenated into a single string, separated by colons. This resulting string should be stored in a variable, which you can reference directly in your Send email action. Here's the smart value you can use to generate the string:

{{#issue.customfield_11517}}
{{#if(exists(emailAddress))}}
{{emailAddress}}{{^last}}; {{/}}
{{/}}
{{/}}

 s1.png

Nur Fatin April 22, 2025

Hey @Akash Singh thanks for the solution. Can I check where should I input the create variable portion in my current rule? Would it be after the "And: Add comment to issue"?

Since there are two custom fields, I just create another one for {{#issue.customfield_11516}}?

I have set it up like this, but couldn't select the variable option and input it as {{BusinessSystemOwner}} and {{TechnologySystemOwner}}:

Screenshot 2025-04-22 at 3.46.40 PM.png

This is the audit log I got when I run it:

Screenshot 2025-04-22 at 3.53.12 PM.png

Am I on the right track?

Thanks in advance.

Akash Singh
Community Champion
April 22, 2025

@Nur Fatin This seems to be correct, can you add a log action and check the value stored in the variable?

Akash Singh
Community Champion
April 22, 2025

@Nur Fatin

Apologies for the confusion, I initially assumed that colon-separated emails within a smart value would be accepted in the To field of the Send email action. However, it turns out that when using a smart value, the To field expects a single email address.

That said, there's still a way to achieve the desired outcome. You can use Advanced Branching to loop through each user in the field, as demonstrated in the screenshot below.

s1.png

Within the branch, you can add a condition to check if the user's emailAddress exists. If it does, you can proceed to send the email to that user. You'll also need to create separate branches for each of the two fields you're targeting.

s2.png

s3.png

Nur Fatin April 22, 2025

Hey @Akash Singh is it possible to do the branch rule first and then outside of the branch, do the send email action? I wanted to input both fields in the "To:" field in the send email action.

So far I set it up like this and the audit log is shown below:
Screenshot 2025-04-23 at 11.22.02 AM.pngScreenshot 2025-04-23 at 11.21.01 AM.png

Akash Singh
Community Champion
April 22, 2025

@Nur Fatin

After reading through @Bill Sheboy’s response, I realized that simply replacing the semicolon with a comma in my original post should allow your automation to work without requiring branching.

Additionally, I noticed that we had been using the wrong custom field ID for those fields. With the correct IDs, the smart values to access each field’s email addresses would look like this:

For Business System Owner,

{{#issue.customfield_12874}}
{{#if(exists(emailAddress))}}
{{emailAddress}}{{^last}}, {{/}}
{{/}}
{{/}}

For Technical System Owner,


{{#issue.customfield_12876}}
{{#if(exists(emailAddress))}}
{{emailAddress}}{{^last}}, {{/}}
{{/}}
{{/}}

You can then simply use both the variables in the Send email action and as long as one of the field has at least one recipient the automation should work.

s1.png

 

Nur Fatin April 22, 2025

@Akash Singh I have set up like this and it has the same audit log error:

Screenshot 2025-04-23 at 2.07.42 PM.pngScreenshot 2025-04-23 at 2.06.04 PM.png

Akash Singh
Community Champion
April 23, 2025

@Nur Fatin

In the screenshot you shared, the log action doesn’t display any email addresses for the fields, which indicates one of two possible scenarios:

a. Both fields might be empty for the Work Item, so no email address was found.
b. The fields are populated, but the user objects don’t include the emailAddress attribute.

To confirm the second scenario, you can inspect the issue’s JSON response directly using the following Jira REST API endpoint. Be sure to replace your Jira site URL and the issue ID before making the request:

https://your-jira-site.atlassian.net/rest/api/3/issue/<ISSUEDID>

Check the values for customfield_12874 and customfield_12876, and look for the presence of the emailAddress attribute in the user objects.

This behavior aligns with a known feature suggestion requesting that the emailAddress attribute be included in the People field object implementation.

I was able to reproduce the issue in my instance as well, see below screenshot. Here my first account doesn't have email present but the second one does.

s1.png

At this stage, if data migration isn't a significant concern, I’d recommend creating two new site-wide multi-user picker fields and using them directly in the automation rule. This approach is more reliable than depending on the People field in team-managed projects, as the emailAddress attribute in the user object can be inconsistent.

 

Nur Fatin April 23, 2025

@Akash Singh I have inspected the issue's JSON response and received the same results as your screenshot. Both customfield_11517 and customfield_11516, I can see an email address. I noted that the customfield_12874 and customfield_12876 were the incorrect ones.

When I tried the same automation set up, create variable with the correct customfields, it is the same audit log of "Unable to send the email as the recipient's email address wasn't provided." as before. In this case, the other option is to get my Jira Site Admin to add user picker field at a global level?

Akash Singh
Community Champion
April 24, 2025

@Nur Fatin Yes, correct. You would be better off asking your Jira Site Admin to create new multi-user picker field at global level for your requirement.

0 votes
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.
April 22, 2025

Hi @Nur Fatin 

Do you expect both fields to always contain selected values?  If so, you may merge them, remove duplicates, and use that in the email address; no branching is required.

For example, if these are global, company-managed multiple-select user fields:

{{issue.customfield_11516.emailAddress.join(",").concat(",").concat(issue.customfield_11517.emailAddress.join(",")).split(",").distinct}}

That works by joining the selected email addresses together with commas, and then concatenating the values for the two fields.  Then they are split back apart into a list before using the distinct function to remove duplicates.

If one (or both) fields could be empty, additional conditional logic is required.

Kind regards,
Bill

Nur Fatin April 22, 2025

Hey @Bill Sheboy thanks for the suggestion. I have tried the smart value provided in the "To:" field in the email, but it still returned the same audit log of "Unable to send the email as the recipient's email address wasn't provided."

Sometimes, one field could be empty, but usually both fields will have one or more users.

My project is a team-managed project, does that make a difference?

Thank you in advance.

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.
April 23, 2025

Just to confirm, what are the types of your fields?

 

A "People" type field in a team-managed project do not provide the email address for users in automation rules.  Here is the defect / suggestion to fix that: https://jira.atlassian.com/browse/AUTO-519

And thus one workaround is to add a global / company-managed user field (single or multiple selection) and use that field in the team-managed project.

Have you done that?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
TAGS
AUG Leaders

Atlassian Community Events