We are on Jira Cloud.
I have automation rule that extracts the account id from the users mentioned in the comments and appends these users to the custom field.
But this only works when the users are mentioned without any text in the comments, which of course defeats the purpose.
This is something to do with regex in the smart value but I can't figure out.
Smart Value : {{issue.comments.last.body.match("(accountid:[^]]+)").remove("accountid:").remove("[~").remove("]").split(" ")}}
Other thing is, that in the audit log it shows that the two user IDs were extracted but only one is appended to the field.
Automation rule has advanced branching and for each smart value work item is edited.
Here is the complete flow (with screenshots)
1. Work Item Commented - All Comments
2. Then create variable {{addUser}}
2.1 Smart value {{issue.comments.last.body.match("(accountid:[^]]+)").remove("accountid:").remove("[~").remove("]").split(" ")}}
2.2 Add value to audit log - Just to see the output, this step can be eliminated
3. For Each Smart Value: {{addSingleUser}}
3.1 Then:add value to audit log
3.2 Edit work item fields - More Options - JSON
{
"update": {
"customfield_10610": [
{
"add": {
"accountId": "{{addSingleUser}}"
}
}
]
}
}