โ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.