I have a custom user field called "Analyst(s)". This is a user field that sometimes only has one user in it or sometimes it might have a couple users in it.
What I want to do is create an automation that leaves a comment on the ticket when that ticket is transitioned to a certain status that @mentions all of the users in that custom field "Analyst(s)".
How do I do this?
You can do that by getting the Atlassian Id for the users in that field via smart value and @ mention them like this:
[~accountId:{{user field name.accountId}}]
Note that if you have multiple users in that field you need to divide it up since you cannot use one [~accountid...] for all of them.
Hi @Frank
Adding to Mikael's answer...
When working with a multiple select user field, your rule may use the list iterator functions to add those mentions. For example:
{{#issue.yourUserField.accountId}}[~accountId:{{.}}]{{^last}}, {{/}}{{/}}
To see other examples of list iterators, please look here:
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.
Thanks Bill this worked perfectly. Would you mind breaking down your answer to help me understand exactly what it's doing? I was confused on this portion in particular
{{.}}]{{^last}}, {{/}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome; I am glad to learn that helped!
For more details on my suggestion...
The {{last}} and {{^last}} smart values are helpful when using a list, to add (or not add in the case of ^) things like a delimiter, as a suffix. In my expression:
{{^last}}, {{/}}
This will add a comma-followed-by-a-space between each item, except the last one. For your comment mentions, this makes it look nicer...but for other things like JSON and math expressions, this helps prevent syntax errors.
There is also a {{first}} operator when a prefix is needed for list values.
Regarding the {{.}} that is the placeholder for each item while iterating over the list. And so for this expression
{{#issue.yourUserField.accountId}}[~accountId:{{.}}]{{^last}}, {{/}}{{/}}
Where we are iterating over any accountId values found in your multiple-select field, it is each value as we loop.
A less cryptic, way to do this would be this:
{{#issue.yourUserField}}[~accountId:{{accountId}}]{{^last}}, {{/}}{{/}}
That would iterate over the user objects selected in the field, and then use just the accountId attribute. All of the other user attributes are available when using this method: displayName, emailAddress, etc.
That link I provided to the combined list examples show things not documented anywhere else for rules, so it may be worth a read to learn more :^)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy i tried a bunch of times in our sandbox but im screwing up the syntax...
same issue as above; we have a customfield (tester) thats a multi user picker...i just want the automation to @ the people listed in that custom field in a comment...here's my code...and the result i currently get without that list iterator stuff done right :) Any guidance appreciated!
________________________________________________________________
{panel} *Automation Mention Final Test* {panel}
\\
* *Hardcoded:* [~accountId:6127b46f3ef46a007078ecf5] , [~accountId:6127b46f3ef46a007078ecf5]
* *Reporter:* [~accountid:{{issue.reporter.accountId}}]
* *Assignee:* [~accountid:{{issue.assignee.accountId}}]
* *Tester:* [~accountid:{{issue.customfield_49919.accountId}}]
\\
\\
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.
For a multiple-selection, user picker field an iterator must be used, as described in my earlier post.
If that does not help, please post images of your complete rule, the action where the mention happens, and of the audit log details showing the rule execution. Those will provide context to help explain what you are observing.
Also, what version of Jira are you using: Cloud, Server, or Data Center?
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.
Thanks for the response @Bill Sheboy its not that it didn't work, i just definateyl didn't do it correctly. it was a bit too "syntaxy" for me to be able to pull off :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What type of project is this: company-managed or team-managed?
And...for the multiple-selection user picker field Tester, please try this to mention all the selected users:
{{#issue.customfield_49919}}[~accountId:{{accountId}}]{{^last}}, {{/}}{{/}}
Please note well: smart value expressions are case-sensitive, so confirm this exactly matches what you try. (When the wrong case is used, the expression often evaluates to null and shows no errors.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its a company managed "instance" but team managed "Projects". Each project within the instance/tenant/whatever has its own admins that work on and deal with just that project, but there are overarching global admins if there is some post function or global access or multiproject thing needed.
That worked @Bill Sheboy ! i must have originally screwed something up in the sysntax. appreciate the help very very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome; I am glad to learn it is working for you!
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.