Forums

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

Accessing User Emails for multi-user fields for looped Slack messaging through Automation

Andrew King January 17, 2024

So I have a use case where I want to Slack message each user for a multi-user field to request them to action an item. 

 

I have this working with Single user fields through requesting the User ID from slack and then formulating another web-request to my Slack bot that messages them. This works.

However when it comes to Multi-user fields I should be able to use the advanced branching component to get each of these users, but the smart value variable doesn't seem to be making it to be injected in my web request as it does with single user fields. 

automation support.png

 

Using logging I know I can log the email addresses for each user of my "Stakeholders" field however using that variable is not allowing me to inject it into my web request. 

 

I suspect I am structuring the advanced branching Smart Value incorrectly to allow it to loop over properly. 

 

I've looked at the support documents for lists and have tried multiple  different iterations but think I need help or have otherwise hit a bug. 

 

Thank you

 

1 answer

1 accepted

0 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.
January 17, 2024

Hi @Andrew King -- Welcome to the Atlassian Community!

Your advanced branch is iterating over the selected users for the field, and those will each be a user object.

In your write to the audit log, you are correctly referencing the emailAddress attribute, but in your send web request  you are passing the entire user object.  Try changing the web request to only pass {{Stakeholder.emailAddress}}

 

Some other things I noted:

There is a typo in your write to the audit log for the smart value: {{shakeholder.emailAddress}} should be {{Stakeholder.emailAddress}}

Next, when naming variables (such as for branches and created variables) I recommend adding a prefix to ensure they do not coincidentally match an issue field.  For example, varStakeholder rather than Stakeholder.  As your variable and field only differ in one letter (i.e., the last "s") a typo could cause errors.

Finally, as your advanced branch is only using the email address, the branch could be changed to only use that field as a source: {{issue.Stakeholders.emailAddress}}  No need to change this; just an FYI.

 

Kind regards,
Bill

Andrew King January 17, 2024

Hi Bill having some trouble replying to your comment

 

I've made those recommended changes and fixed the typo and rechecked.

Smart Value is now = {{issue.Stakeholders.emailAddress}}

Variable name = varStakeholder

 

Automation 3.pngAutomation 5.png

 

It's correctly writting to the audit log, but still not injecting into the web request. Any additional help is greatly appreciated

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.
January 17, 2024

I wonder if the cause is a URL encoding issue for the Slack REST API call.  Please try changing the request URL to use this for the stakeholder value:

{{varStakeholder.urlEncode}}

 

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#urlEncode--

Andrew King January 17, 2024

Sadly the same result with that one

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.
January 17, 2024

Just to confirm when you write the {{varStakeholder}} smart value to the audit log inside of the branch, you see the email address.  Correct?

And if you write the entire URL for your request to the audit log (copying it directly from the "Web request URL" field in the action), does it look as you expect?

Andrew King January 17, 2024

Success.

So whilst the Web Request Validator doesn't appear to work for For Each: Smart Value. I was actually logging the incorrect Response:

{{webResponse.user.id}}

 

When it should have been: {{webResponse.body.user.id}}

 

Thank you very much for your help. Human error by me for the most part!

Like Bill Sheboy likes this
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.
January 17, 2024

Awesome; I am glad to learn it is working!

Suggest an answer

Log in or Sign up to answer