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?
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}}
{{/}}
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...."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great glad to hear that. Nice workaround.
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.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Demetris Karacostas Exactly what I needed. Thank you!
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.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!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.