Automation: convert mention to a username in text

Fernanda Malcolm
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!
February 22, 2024

Hi,

I've created an automation to copy comments from the original issue to a cloned issue. The problem is that any mention triggers a notification to the users mentioned. I would like to know how to convert any mention in the comment to text, so that the notifications are not triggered.

 

Many thanks

4 answers

0 votes
Luka Hummel - codefortynine
Atlassian Partner
February 23, 2024

Hi @Fernanda Malcolm

If you are willing to try a third-party app you could try our app Deep Clone for Jira. Deep Clone can clone issues including their comments, and there is an option to suppress notifications for mentioned users.

2024-02-23 16-09.png

0 votes
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.
February 22, 2024

Hi @Fernanda Malcolm 

It would be easy to "break" the mention syntax (using the replaceAll function) so adding a comment no longer mentions someone, but it seems you want to replace the mentions with the display name of the users.

To learn if this is possible, we would need to see your rule and observe how you are copying the comments.  For example...

  • If the rule is copying all the comments in one block to add as one comment (and so preserve their ordering), the replacement of account id values with display names will not be possible with built-in features
  • If the rule is iterating over comments to add them with an advanced branch, and more than one user is mentioned per comment, the replacement will not be possible

The scenario that might work in a rule is when there is a branch over comments and zero-or-one user is mentioned.  That could use a REST API function call to find the display name of the user for replacement.  As that will potentially be a very slow rule, you may not want to do this as it could exceed your automation service limits for rule run time execution.

Another option would be to write an external service which performs all the replacements and adds the comments, in the correct order, and then call that service from the rule with a Send Web Request action.  At that point, it may be better to use a marketplace addon for cloning.

Kind regards,
Bill

0 votes
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 22, 2024

Hi @Fernanda Malcolm

This one is a bit tricky.  You can extract the user id from the @mention by using this smart value:

{{comment.body.match("\[~accountid:(.*?)\]")}}

The challenge comes in converting that.  Smart Values can only work against a user field (e.g. reporter, assignee, custom field) so in order to take the next step of getting the display name, you have a couple options:

  1. Use a placeholder custom field:
    1. Create or repurpose a custom field.  This will not need to be added to issue screens. It'll just be used long enough to capture the user information
    2. Before your clone action, use the Edit Issue action to update the custom field from above
    3. In your copy comment action, you would do something like this
      1. {{comment.body.replaceALL("\[~accountid:(.*?)\]",issue.YOURCUSTOMFIELD.displayName)}}
  2. Use the Jira API: If you're more technical, you could hit the Jira API via the Send Web Request action to convert the account id into a display name

 

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 22, 2024

Hi Fernanda,

Since it is cloning all of the items, I don't think there is a way to control that in the middle of the cloning process for a single field. The only think might be to edit the comment before you clone the issue. Maybe leave the name but put in a space between the @ and the name. Something like: Hey @ johnfunk - this is good to go. 

Suggest an answer

Log in or Sign up to answer