How to: Add all @-mentioned users/customers (in the comment) to the Request Participants.
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
Often time business process flows require that the users/customers mentioned in the comments are to be added to the request participants list. This is not possible out of the box. This article presents a solution using automation.
Environment
Jira Service Management cloud
Please generate Basic Auth Credentials for REST API
Under the heading "Supply Basic Auth Headers" of this document, please follow the steps 1-3 and copy the final string in the "Authorization" header value for all 3 "Send Web Request" action.
Solution
Two conditions are checked before adding request participants.
The comment is not an internal comment, and the body of the comment contains at least one user mentioned.
Finally, using the ''Send web request* action, add all mentioned users to the request participants list.
REST Endpoint:
{{baseURL}}//rest/servicedeskapi/request/{{issue.key}}/participant
Payload:
{"accountIds":[{{#issue.comments.last.body.replaceAll("\\n", "").split(" ").substringBetween("[~accountid:", "]")}}"{{.}}"{{^last}},{{/}}{{/}}]}
Explanation of functions in the payload
replaceAll("\\n", "") : Removes/replaces-with-empty all new-line characters from the comment body before extracting user account IDs.
split(" ").substringBetween("[~accountid:", "]") : splits the words/tokens that the expression substringBetween("[~accountid:", "]") produces which are basically the account IDs and converts the list of accountIDs int o an array for processing/iteration.
This whole payload code will generate the json that will be used by the web request to add all users as request participants.
Automation Rule .json (imported) file. Please refer to this article to learn more about Import and export Jira automation rules.
Automation rule exported .JSON file
automation-rule-20992998-202408252319.json