04-02-2024 02:05 PM
Hi,
Solved! Go to Solution.
04-02-2024 10:55 PM
When you have an array like ListOfCamp, you can access any item in the array by putting the index number of the item in brackets like ListOfCamp[0] or ListOfCamp[1].
When you make a repeat helper and use it to start a repeat loop, the loop action provides an index data pill starting at zero and ending at the size of the loop. Each loop increases the index by 1.
Understanding this is really important when trying to use a repeat helper to iterate through an array that is not a traditional “list” in Workato (in other words, an array that cannot be directly looped). Especially a primitive array like ListOfCamp.
Within the loop, you want to “add item to list” and use the ListOfCamp data pill with the index data pill of the loops action. Should look like:
ListOfCamp[index data pill from loop]
The way it’s set up now is erroneous because you’re not providing an index value for ListOfCamp and assuming it is being iterated through, but it’s not. It’s just passing the entire array, which is why your output has the entire array.
In your screenshots you’re using split on ListOfCamp but this seems incorrect because split should only be used on strings. (I’m actually surprised it’s not crashing — I didn’t think split would work at all on an array.)
I’m assuming you intend to split the string items in ListOfCamp, but this is not the way to do it. I also assume that once they are split, you want to add each individual result from each split string to the UniqueCampaigns list. This is possible but also requires a different approach, but I’ll wait for you to confirm first.
04-02-2024 09:25 PM
Should I be using Variables instead of Lists? I see where Variables supports "Create a list" and "Add Items to a list".
04-03-2024 02:48 AM
Hi @JayMappus ,
When we have an array say name: ListOfCamp, you can access any item in the array by giving an index number of the item in brackets like ListOfCamp[0] or ListOfCamp[1].
When you make a repeat helper list and use it to for a repeat loop, the loop action provides an index data pill starting at position zero and ending at the size of the loop. Each time increases the index by 1 for the next instance.
Could you please provide guidance on the preferred format or structure for the response?
04-02-2024 10:55 PM
When you have an array like ListOfCamp, you can access any item in the array by putting the index number of the item in brackets like ListOfCamp[0] or ListOfCamp[1].
When you make a repeat helper and use it to start a repeat loop, the loop action provides an index data pill starting at zero and ending at the size of the loop. Each loop increases the index by 1.
Understanding this is really important when trying to use a repeat helper to iterate through an array that is not a traditional “list” in Workato (in other words, an array that cannot be directly looped). Especially a primitive array like ListOfCamp.
Within the loop, you want to “add item to list” and use the ListOfCamp data pill with the index data pill of the loops action. Should look like:
ListOfCamp[index data pill from loop]
The way it’s set up now is erroneous because you’re not providing an index value for ListOfCamp and assuming it is being iterated through, but it’s not. It’s just passing the entire array, which is why your output has the entire array.
In your screenshots you’re using split on ListOfCamp but this seems incorrect because split should only be used on strings. (I’m actually surprised it’s not crashing — I didn’t think split would work at all on an array.)
I’m assuming you intend to split the string items in ListOfCamp, but this is not the way to do it. I also assume that once they are split, you want to add each individual result from each split string to the UniqueCampaigns list. This is possible but also requires a different approach, but I’ll wait for you to confirm first.