Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation help - How to Use local variable outside of branch

Priyanka Agrawal
November 16, 2025

I have an automation rule that receives a payload from an external system.
Example payload is as below-


"payload": {
"eventName": "add_update_shipment_info",
"version": "2.0",
"opportunityName": "abc-34514",
"shipment_name": "WH/OUT/abc-34514/1",
"shipment_id": "473397",
"shipment_url": "https://www.xyz.com",
"shipment_status": "Planned",
"committed_ship_date": "2025-10-14T09:30:00Z",
"planned_ship_date": "2025-10-14T09:30:00Z",
"actual_ship_date": null,
"committed_pickup_date": "2025-10-14T10:00:00Z",
"planned_pickup_date": "2025-10-14T10:00:00Z",
"actual_pickup_date": null,
"committed_delivery_date": "2025-10-22T03:45:00Z",
"planned_delivery_date": "2025-10-22T03:45:00Z",
"actual_delivery_date": null,
"tracking_info": {
"carrier": null,
"shipping_method": null,
"shipment_source": null,
"tracking_code": null,
"tracking_url": null,
"number_of_boxes": null,
"delivery_status": null,
"signed_by": null
},
"mfg_dris": [
{
"platform_user_id": 68549,
"email": "priyanka.agrawal@xyz.com",
"first_name": "Priyanka",
"last_name": "Agrawal"
},
{
"platform_user_id": 68550,
"email": "abc.def@xyz.com",
"first_name": "abc",
"last_name": "def"
},
{
"platform_user_id": 68551,
"email": "api-jira@xyz.com",
"first_name": "API",
"last_name": "Jira"
},
{
"platform_user_id": 68553,
"email": "api-auto@xyz.com",
"first_name": "api",
"last_name": "auto"
}
]
}
}


The payload contains multiple email addresses under mfg_dris.
I need to tag all these users in an issue (created after the branch) in a custom field called MFG-DRI, which is a multi-user field.

I'm successfully fetching the account IDs for each email address via the Jira REST API by looping over each email address from the payload and storing them in a variable.
However, I'm unable to access or use that variable outside the branch in order to update the custom field on the issue.

I've tried several approaches, such as:

- Initialising the variable before the branch

- Creating the issue first and then updating it using the account IDs via the Update Issue API

…but none of these methods have worked so far.

Could anyone suggest the correct way to use the variable (containing the account IDs) outside the branch so I can populate the MFG-DRI field on the issue?

Another approach I tried is:
1. Create the issue first and then fetch the account IDs inside a branch by looping over each email address from the payload.
2. Store the account IDs in a text custom field.
3. Use "Update issue" API to update MFG-DRI field on the newly created issue by copying values from the text custom field on step 2.

But, this solution causes parallel race condition i.e. multiple automation actions run at the same time to update the same issue, and they overwrite each other or run in the wrong order) when there are more email addresses (I tried for 4 email addresses).

See screenshot for the automation I tried:
image.jpg

 

and here is what I mean by parallel race condition:
image (7).png

Please suggest if you know a way to tag all the email addresses from the payload to a multi user field. The count of email addresses may vary in the payloads.

2 answers

0 votes
Dick
Community Champion
November 17, 2025

Hi @Priyanka Agrawal 

It seems you create the useraccountIDs variable inside the branch. That means that every time that an mfg is processed, this variable is re-made from scratch, so it loses the prior content.

Creating this variable before entering this branch would be beneficial. 

Kind regards,
Dick

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 Champions.
November 17, 2025

Hi @Priyanka Agrawal 

Without seeing your entire rule for context...this is not possible as you described it.

Rule branches on more that one thing are run in parallel and asynchronously with no guarantee of when the branch will complete up until the last step of the rule.  Thus, a variable cannot be created before, updated during, and used after the branch.  (There is an edge case when a branch can only possibly have one thing, such as for branch on current issue.)

 

Although a multiple-select user field may be set to a single value using an email address, it cannot take a list of addresses (based on my testing).  And neither can a JSON accept email addresses for an update.

And, after the privacy changes from a few years ago, I do not believe it is possible to bulk-get users with their email addresses to perform a single get-users, filter by email address, and update of the user field.

 

There is a brittle workaround with a two-rule approach, where one is recursive using an Incoming Webhook Trigger, but I would not recommend it for this scenario.  And, it is limited to up to 10 loops, and subject to problems if Atlassian has an outage impacting rule execution.

Some other workarounds are:

  • Change your source feed to call the REST API and get the user's accountId value, passing that
  • Build an intermediate service to call with Send Web Request from the rule which can perform the lookup / update synchronously, preventing the racetrack timing problems
  • Review your entire rule to determine other approaches

 

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events