cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to accumulate items to a list to use in a "Repeat for Each" loop

JayMappus
Deputy Chef III
Deputy Chef III

Hi,

 
I am struggling to create a list is a proper format to be used later in a "Repeat for each" loop. I begin by using the "Create repeat helper" list where its output is below, ready for the 3 values for to be added.
Screen Shot 2024-04-02 at 4.41.49 PM.png
 
I then have a variable with the 3 values, (output below).
Screen Shot 2024-04-02 at 4.57.41 PM.png
 
Yet when I try to add  the variable  values to the "Accumulate" action I get the following output that the later "Repeat for Each" loop doesn't work.
Screen Shot 2024-04-02 at 4.47.58 PM.png
 
My datapill and formula to the Accumulate action is:
Screen Shot 2024-04-02 at 5.02.21 PM.png
 
I appreciate any help that can be given. 
Thanks
J
1 ACCEPTED SOLUTION

gary1
Executive Chef II
Executive Chef II

 

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. 

 

View solution in original post

3 REPLIES 3

JayMappus
Deputy Chef III
Deputy Chef III

Should I be using Variables instead of Lists? I see where Variables supports "Create a list" and "Add Items to a list".

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?

gary1
Executive Chef II
Executive Chef II

 

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.