Forums

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

Jira Cloud Automation: how can I get a user name from accountid?

Mikael Kalla
Contributor
August 27, 2020

Hi,

In Jira Cloud  Automation, I've set an automation to send last comment to a custom text field "Last Comment" by using

"When: issue commented"

"Then: Edit issue" and "Last Comment" {{issue.comments.last.body}}

This works really good, except that any comment where a person is mentioned as

"@xxxx" appears in my "Last Comment" text field as the user ID, like

"[~accountid:112c123c123c123]" 

Is it possible to have Jira automation to replace this ID with the real user name? 
Or in some other way get the user name from the "@xxx" in the comment?

3 answers

1 accepted

0 votes
Answer accepted
Prince Nyeche
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.
August 28, 2020

Hi @Mikael Kalla 

Usernames are deprecated on Cloud, so don't even bother searching for it. Instead you can use Display Name, if you're trying to show some form of string to identify a user. Try the below example and let me know if that's what you're looking for?

{{#issue.comments.last}}
Comment by: {{author.displayName}}
{{body}}
{{/}}
Mikael Kalla
Contributor
August 28, 2020

Hi Prince,

Thanks, I know about user names are deprecated, I just want the name instead of the accountid of a user mentioned in a comment.

I am not looking for the author of the comment.

Example, I write a comment like: "@Mikael what is the status......."

Then I want as result in my custom text field: "Mikael what is the status..."

But I get "[~accountid:112c123c123c123] what is the status...."

Prince Nyeche
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.
August 28, 2020

Unfortunately, I don't think that you can retrieve such information with Automation. However if your custom field is a multi-line text field with wiki style renderer enabled on the Field configuration, it will render the user on the custom field as you've highlighted, that's the only way possible.

Mikael Kalla
Contributor
August 28, 2020 edited

Would it be possible to read from the comment the [~accountid:112c123c123c123] to a custom user field, and have that to show the name of the mentioned user?

If so, how to remove all text before and after the [~accountid:112c123c123c123], otherwise the automation will fail.

And how would the Jira Cloud automation script look like?

Prince Nyeche
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.
August 28, 2020

Thinking about this, my thought goes to using the match() but i'm not certain you can strip the entire string (left and right side) out leaving only the accountId.

Mikael Kalla
Contributor
August 28, 2020

I managed to solve the extraction of the account id by using "substring" and look for 
"id:" and "]" in the comments field

{
"fields": {
"LastUserCommented": {"id": "{{issue.comments.last.body.substringBetween("id:","]")}}" }
}
}

 

So a comment like  "How are you @Mikael ?"

(which actually is "How are you [~accountid:123c123c123c123c...] ?")

Sends the user id of Mikael (123c123c123c123c..) to the "LastUserCommented" field (custom single user field) and there appears as "Mikael"

Then I can have a filter showing that column

Like 2 people like this
Prince Nyeche
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.
August 28, 2020

Great glad to hear that. Nice workaround.

Mikael Kalla
Contributor
August 28, 2020

Thanks, have a nice weekend!

3 votes
Demetris Karacostas
Contributor
January 13, 2023

@Mikael Kalla isn't using {{issue.comment.last.body.text}} much easier than extracting the user ID?

This should allow to have the display name of the user instead of the user ID value.

Scott Adams
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 3, 2023

@Demetris Karacostas Exactly what I needed. Thank you!

Like Demetris Karacostas likes this
Demetris Karacostas
Contributor
March 3, 2023

@Scott Adams glad this helped!

1 vote
Demetris Karacostas
Contributor
November 17, 2021 edited

Hello,

If you would like the body of the last comment with the name of the user instead of the userid when the user is mentioned, you could use the below:

{{issue.comment.last.body.text}}

Thanks!

 

Reference:

https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Can-we-include-display-name-of-user-mentioned-in-a-comment-in/qaq-p/1170054

Slava Gefen
Contributor
October 1, 2024

Hey @Demetris Karacostas you saved my day 👏

I almost started to write an advanced branching {{smart-value}} and logic to make this replacement 🙃

With kind regards
Slava

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events