How to display the username correctly from the user picker field via Automation for JIRA Data Center smart values
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
These are the users added to the user picker field:
userA, userB, userC, userD, userE, userF, userG, userH
The script in the post comment action in Jira Automation is written in text mode as follows:
Single User:
1
[~{{issue.customfield_10000}}]
Multi Users (Test 1):
1
{{#issue.customfield_10000}} [~accountid:{{accountId}}] {{^last}}, {{/}}{{/}}
Multi Users (Test 2):
1
{{#issue.customfield_10000}} [~{{accountId}}] {{^last}}, {{/}}{{/}}
Multi Users (Test 3):
1
{{#issue.customfield_10000}} [~accountid:{{issue.customfield_10000.accountId}}] {{^last}}, {{/}}{{/}}
However, it does not successfully listed all the usernames. It works for some users not others and the results are as follows:
This is what the mentions look like in the comments:
1
[~JIRAUSER22006] , [~JIRAUSER32410] , [~JIRAUSER30323] , [~JIRAUSER24701] , userE , userF , [~JIRAUSER30236] , userH
Some users resolve successfully but some are just listed as "JIRAUSERXXXX".
Environment
8.20.1
Cause
Prior to version 8.4.0, user_keys were equal to the user first username, which made them almost always equal to the current username, however, starting on Jira 8.4.0 to comply with GDPR policies and reduce the number of places where we store users’ personal data, we’ve changed this approach so that all user keys for new users (no changes were applied to existing users) have the new format = "JIRAUSERXXXX".
We have documentation explaining the username changes:
Solution
Add this smart value format in the "Add a comment to issue" action:
1
{{#issue.customfield_10000}}[~{{name}}]{{^last}},{{/}}{{/}}
ℹ️ Replace customfield_10000 to the custom field id from your Jira instance.
Then, trigger the automation to add a comment to the issue and you will be able to see the newly comment has display the list of users correct username instead of "JIRAUSERXXXX".
Was this helpful?