Forums

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

How can I convert an accountId back into a user?

Brock Jolet
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.
October 6, 2021

I have a convoluted setup where one automation triggers a webhook that in turn triggers a second automation. On the second automation I am thus unable to use {{initiator.displayName}} to display who originally caused the chain of events.

What I was able to do is capture the initiator in the first automation and pass it forward via the webhook as a value called initiator. I can then use {{webhookData.initiator}} to access that accountId on the second automation.

{
"issues": [
"{{issue.key}}"
],
"initiator": "{{initiator}}"
}

 

If I add this value to a user picker, it works fine, but I want to use it in the body of an email.

I tried this:

{{webhookData.initiator.displayName}} has requested approval for {{issue.key}}.

But the result was:

 has requested approval for CM-1.

 

If I don't use displayName, it returns the accountId.

 

Any suggestions for getting a first and last name as text from this variable?

1 answer

1 accepted

3 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.
October 6, 2021

Hi @Brock Jolet 

Since GDPR, I believe you would need to use the accountId value, call the REST API to get user, and then use the response provided display name:

https://docs.atlassian.com/software/jira/docs/api/REST/1000.824.0/#api/2/user-getUser

As an alternative...you could take a chance the accountId is always associated to at least one issue in the project, and then use a JQL query with the ID value (e.g. with a branch or lookup issues), then get display name.

Kind regards,
Bill

Brock Jolet
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.
October 7, 2021

Thanks, Bill.

I ran some tests and I believe this would work, but I ended up creating a custom field and just populating it with the initiator along the way.

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.
October 7, 2021

Good idea, as that will be faster than calling the REST API to get it.  If you want to "hide" that value so it is less likely to be tampered with in the custom field, consider adding it as an entity property instead.

Like Brock Jolet likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events