Forums

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

Iterate Over comma separated string

Ricardo Gonzalez November 20, 2024

I want to iterate over a string that contains accountIds, that is pulled from a "Request Participants" field. Use those values to then update a custom field (multiuserpicker) with those same account ids. 

2 answers

1 vote
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 Leaders.
November 23, 2024

Hi @Ricardo Gonzalez 

I recommend not using a branch to solve this scenario...

Branches which could be on more than one thing run in parallel and asynchronously, with no guarantee of the processing order or when the branch will complete...up until the last step of the rule: https://support.atlassian.com/cloud-automation/docs/jira-automation-branches/#Ordering-of-branch-executions

Thus for your scenario, the different calls to Edit Issue could collide, leading to rule errors or the edits "walking over" each other and not saving as expected.

 

Instead, try to iterate over the values to build dynamic JSON and the use one single Edit Issue action with the JSON.  Please update the custom field id values in the expression below to match your fields.

{{#if(exists(issue.customfield_10027.accountId))}}
{
"update" : {
"customfield_10964" : [
{{#issue.customfield_10027.accountId}}
{ "add": { "accountId": "{{.}}" } } {{^last}}, {{/}}
{{/}}
]
}
}
{{/}}

 

Kind regards,
Bill

0 votes
Trudy Claspill
Community Champion
November 20, 2024

Hello @Ricardo Gonzalez 

Are you trying to create an Automation Rule for this? If so, please show us what you have so far.

Ricardo Gonzalez November 22, 2024

Screenshot 2024-11-22 at 10.56.30 AM.png

 the "test" field returns a string that contains two accountIDs split by a comma. 

I then want to use that list/string to iterate over (which is the addCustom).

 

Screenshot 2024-11-22 at 10.58.04 AM.pngI would like to update my custom field with those values. But I am not following how to iterate over the string and to update and insert an accountID for every value of that string

Trudy Claspill
Community Champion
November 22, 2024

Thank you for that additional information.

Please show the details of the Branch step.

Ricardo Gonzalez November 22, 2024

Would you mean this portion? Screenshot 2024-11-22 at 12.52.49 PM.png

Trudy Claspill
Community Champion
November 22, 2024

Yes, thank you, that was what I was requesting.

To iterate over a list of comma separated values you need to use the split function:

Screenshot 2024-11-22 at 11.59.28 AM.png

Teri Michaels
Contributor
September 17, 2025

I've tried to repeat these instructions and I can't get advanced branching to iterate. It just treats the comma separated list as a single item.
image.png
I would expect the Log Action to have 9 different logs, but it only does the log action once with the entire string. image.png

Trudy Claspill
Community Champion
September 17, 2025

Hello @Teri Michaels 

The results you are getting are correct.

Within a branch you don't get separate Log action entries in the audit log for each iteration of the branch. It is still executing the branch for each value though. You could prove that by using a more complex Log action statement that makes some change to each value, like making some change to the branching variable as part of the smart value you log.

Like Bill Sheboy likes this
Teri Michaels
Contributor
September 18, 2025

So this is what I would like to do with this branch. Lookup work items with the iterated variable from the split. And then link that list of tickets from the lookup to the ticket. 
image.png

 But it only does a search one single time on that long string of characters and faults. If it was separating and doing the search on each section, it shouldn't fail.

image.png

Any idea how I'm getting this wrong?

Trudy Claspill
Community Champion
September 18, 2025

Hello @Teri Michaels 

Given that the original post to which you have added is almost a year old, and adding on to posts older than 6 months is discouraged by the Community Guidelines (re: necroposting), I recommend that you start a new Question by clicking the +Ask a question button at the top of the Forums screen.

In your new post include a link to this original post as a reference, but also re post the details of your scenario and screen images.

Please also provide a screen image that shows your entire automation rule, and the details of each step where you use a smart value or JQL statement.

Like # people like this
Trudy Claspill
Community Champion
September 19, 2025

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