cancel
Showing results for 
Search instead for 
Did you mean: 

Iterating over a list of strings

eddabm
Deputy Chef I
Deputy Chef I

Hey,

I have a look up table containing two columns, one is a template ID and another is an item ID. I want a unique list of template IDs, and then I want to iterate over them. 

I've got the unique list using pluck and uniq (testing within a logger step): = <All entries from lookup table>.pluck(["entry", "col3"]).uniq

However I can't do anything with the result. If I add a repeat for each, I can't enable formula mode or use the output of the logger action. Similarly, if I try and create a list, it insists on a schema but seemingly you can't define a schema unless it's a list of objects rather than strings. I thought perhaps I could use format_map to create a list of objects, but it still remains as a string so that doesn't help either.

I suspect I'm just approaching this the wrong way, can I get some advice on how to approach this? 

1 ACCEPTED SOLUTION

gary1
Executive Chef III
Executive Chef III

When you have a raw array, there are a couple ways to put it into a Workato list for iteration. Here’s an easy one:

First, use List > create repeat helper, and use array.size as the input value. This helper action will output a dummy Workato list the same length as the array. It also has an index data pill. You will use this to transform your raw array into a Workato list. 

Next, create a list or variable list and do a bulk add. Use the repeat helper dummy list as the input list, and then you have to manually map the list items using your array data pill, the repeat helper index data pill, and the key names (but since you’re using pluck, you won’t have key names but only indexes). 

For example: array[index data pill][0] should get the “entry” value, and [1] will get the “col3” value. 

 

View solution in original post

1 REPLY 1

gary1
Executive Chef III
Executive Chef III

When you have a raw array, there are a couple ways to put it into a Workato list for iteration. Here’s an easy one:

First, use List > create repeat helper, and use array.size as the input value. This helper action will output a dummy Workato list the same length as the array. It also has an index data pill. You will use this to transform your raw array into a Workato list. 

Next, create a list or variable list and do a bulk add. Use the repeat helper dummy list as the input list, and then you have to manually map the list items using your array data pill, the repeat helper index data pill, and the key names (but since you’re using pluck, you won’t have key names but only indexes). 

For example: array[index data pill][0] should get the “entry” value, and [1] will get the “col3” value.