Automation | Identify users mentioned in comment and add them to custom Field

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

The following automation rule will help to identify the users from the added comment and add them in the desired custom field. This rule will also keep existing users in custom field and will add new ones mentioned in comment.

Environment

Jira Cloud

Solution

This rule will process the comment as mentioned below:

Trigger : When Issue is Commented

Action :

  • Create a variable that contains all the account ids mentioned in the comment. To fetch Ids, it will use a regex: 
{{issue.comment.last.body.split("\n").match("\[~accountid:(.*)\].*")}} 
  • Create next variable by removing string '~accountid:' from the previous step.

  • Create next variable by removing '[' from the string of previous variable
  • Similarly ']' and ' ' is removed from the strings and a final variable is created whcih only contains the Atlassian account id of users mentioned in comment. In example this variable is named - 'finaluserlist'
  • Then it fetches the existing users mentioned in custom field and stores it in 'existingusers' variable
  • As final step, add both these variables in desired custom field (it should be of the type user picker). In this example field name is "Approver"


Automation Rule JSON File (which can be imported in site directly) :

 automation-rule-14581527-202308311619.json


Note : In last second step where we create existingusers variable, customfield id needs to be used. Please replace id in rule with id of your customfield.


Last modified on Aug 31, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.