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.
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
Hello @Ricardo Gonzalez
Are you trying to create an Automation Rule for this? If so, please show us what you have so far.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
I 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for that additional information.
Please show the details of the Branch step.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
I would expect the Log Action to have 9 different logs, but it only does the log action once with the entire string.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
Any idea how I'm getting this wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for creating a separate Question, @Teri Michaels
I see that @Bill Sheboy provided an answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.