Loop is not working as expected—what am I missing?

Hi there,

I want to loop through an array that I’m generating:

If I manually input the value to test, everything works as expected.

However, if I try running that loop from the workflow, then it doesn’t seem to work and I get an array of 18 nulls (the same length as the provided array).

The logs don’t seem to surface the content of the loop too:

I have a hunch that it has to do with that value parameter:

but if I don’t specify that, I can’t access value from within the loop (reference error, value is not defined)

What am I missing here? How can I fix this?

Thanks in advance for your help!

Thinking this might be a bug/glitch, I tried recreating the loop function from scratch... Still facing the same issue.

I even made so that the multistep function only has a response step connected—which again works in test but not when I'm trying to run it from the workflow

Ended up recreating the loop one action at the time.

(i.e.:

  • created a response step, ensured it worked and returned the value i expected
  • added the first AI step, ensured it worked
  • added the second AI step, ensured it worked
  • added the code step, ensured it worked
  • ran the workflow, confirmed it worked
    )

the only other change is that I connected the loop directly to the step providing the data, instead than after the SQL query.

I have absolutely no clue what changed, the content and set up is virtually identical ¯_(ツ)_/¯

Hi @jp_resend,

Apologies for the confusion, from a quick glance it looked like everything was set up correctly. I had a suspicion as you did that it may be related to the {{value}} you were passing in, maybe that or another piece of data needed to be keyed into one more level.

And I was going to ask for a JSON export with some dummy data to test it out.

Does your last comment mean that on the second rebuild it is working now? :sweat_smile:

I wonder if connecting the loop to the step providing the data was the issue then :thinking:

Hi Jack,

The step was connected so I don't know exactly what was going wrong.

Things are working now.

Thanks,

1 Like

Glad to hear it, @jp_resend! Let us know if you have any additional challenges.