We are on Jira Cloud.
OBJECTIVE: To retrieve the account id from the display names and update custom field.
USE CASE: When a user mentions another user(s) in an email reply to a work item these user names show as display names in Jira. I have an automation rule that filters out the display names, constructs email address. Then I use API call in Branches to get account ID for each email address.
MAIN ISSUE: Issue here is that in branching the custom field is not being edited because, as per my understanding, the variable in which account ID is stored resets each time values is added to it.
METHOD 1 (partially successful): USE SEND WEB REQUEST ACTION FOR EACH EMAIL ADDRESS TO RETRIEVE ACCOUNT IDs
I used Advanced Branching. For each email address API GET call is made to retrieve the account ID. AccountID is stored in a variable. JSON is used to update the custom field. JSON is stored in a variable and EDIT Action with Advanced Editing that contains the JSON variable. This ofcourse, doesn't work
Here are the complete steps followed by screenshots:
1. Trigger -> All Comments - Rule is run when a new comment is added to a work item
2. Create variable getDisplayNames filters the mentioned display names from the comment
Smart Value: {{comment.body.match("@(\\S+\\s\\w+)")}}
3. Create variable varEmailAdrs constructs email address from display names
Smart Value: {{getDisplayNames.split(",").trim().join("@domain.com,").replace(" ", ".")}}@domain.com
4. BRANCH
4.1 Create variable varEmailAdrsSplit splits the varEmailAdrs by comma (",")
Smart Value: {{varEmailAdrs.split(",")}}
4.2 SEND WEB RQUEST action
<API URL>/user/search?query={{varEmailAdrsSplit.urlEncode}}
4.3 Create variable apiResponseAccountId to retrieve the account ID
Smart Value: {{webResponse.body.first.accountid}}
4.4 Create Variable varJson value:
{ "update": { "customfield_10610": [ { "add": [ { "accountId": "{{apiResponseAccountId.trim()}}" } ] } ] } }
4.4 Edit Work Item, Advanced Editing {{varJson}}
I have no issues else where. API request is successful, the Audit Log shows "success". Just need to append the account IDs to custom field that is all!


Thanks!