Search code examples
google-cloud-platformnested-loopsgoogle-workflows

Can variables be passed into nested for loops?


I have a for loop that iterates with a value: design.

I have another for loop that iterates within each design with the value: array.

I need to access a property of the parent design within the array like this:

${design.string_inverters[array.string_inverter.index].name}

Upon execution, however, I get an error "key not found". Is this because the value from the parent for loop is not passed down? Or is this an error with my syntax within the index?

Note: I have validated the response and the key does exist within the design object


Solution

  • The problem was that I needed to reference a different variable. The design variable mentioned was correctly being accessed, but the string_inverters property was on a different object. I had them confused. You are able to reference the variables inside of nested for loops as intended.