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:
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:
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.
@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}}; {{/}}
{{/}}
{{/}}
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}}:
This is the audit log I got when I run it:
Am I on the right track?
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nur Fatin This seems to be correct, can you add a log action and check the value stored in the variable?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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.