Is there a way to decode or remove user mention in the body of a comment when using smart values

Chris Byrne June 9, 2021

Is there a way to decode or remove user mention in the body of a comment when using smart values?

I am sending an email when an issue meets a certain criteria and would like to include comments but the user mentions displayed are ugly. I would like to remove or decode the accountID to user name.

Example

[~accountid:557058:3242d09a-2bc3-45d8-9e23-c4f297841a63]

TL/DR

I am a little sketchy on the specific implementation...

3 answers

2 votes
Pierre-Yves Dufour August 8, 2023

Yes @Chris Byrne 

I've sucessfully achieve this by adding .text at the end
Example : {{issue.comments.last.body.text}}

At least it solve the problem for an integration with Slack.. didn't test it for an email....

1 vote
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.
June 9, 2021

Hi @Chris Byrne 

Removing them is easy, if you do not mind any gaps in your comments.  Please try the replaceAll() function with a regular expression to remove everything surrounded by the brackets.

{{#issue.comments}}
{{body.replaceAll("(\[.*\])", "")}}{{/}}

If you want a placeholder, you may replace the empty "" with something else, like "USER-MENTION".  Please see this documentation for more about that function:

https://support.atlassian.com/jira-software-cloud/docs/smart-values-text-fields/#Smartvaluestextfields-replaceAll-Stringregex-Stringreplacement-

Best regards,

Bill

0 votes
K_ Yamamoto
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 11, 2021

Hey Chris - I found there's no straightforward way to achieve your requirement.

Consider voting for the feature request tracked at JRACLOUD-77167.

Suggest an answer

Log in or Sign up to answer