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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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

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