Accessing Values in Loop to Use in Another Loop?

I have a workflow that iterates of a table of products snowflake using a loop block which results in an array output. I need a next loop block to iterate over the data from the cp_fitment loop and run that SQL query in the modded_fitment but I am unsure what I put in my placeholder spot {{value here}} in the where clause

I have tried various things and am stuck here as {{value.me_vid}} does not work given its nested as an object in the array.

My final js block will store these values from snowflake cp_fitment and modded_fitment of which I will be using to trigger a SQL insert query.


I am just stuck on how to access each value from the 1st loop so my second loop iterates over each value

Hi @seandawes!

Wondering why you have an output there of an array inside an array for the first loop? But regardless, I would:

  1. use a transformer to output an array of just the me_vid, output should be [1095, 1099, ...], depending of course if that should be INT or STRING as your data type in your database/data warehouse. i.e. return[0].map(x => x.me_vid)
  2. use a snowflake read block and use the operator IN, (docs here) so you don't have to waste the looping part. If it is MySQL, then it's straightforward, see below:

Essentially, you'll have something like this:

FROM spree_vehicle_data
WHERE id IN {{ }}

And then you connect this block to your final block.

1 Like