Value and index undefined in loop

I am building out a workflow that has a query, that leads to a loop that has a workflow lambda inside of it. when I try to access the value to pass to the workflow it says that value and index are underfined. If I use a JS Code Lambda in the loop I can access value and index. But I've tried workflows and Retool AI and they both say value and index are undefined.

See image below.

I should add that I've tried value with and without the moustache handlebars. It's treated as a string without the curly braces. I've also review the other tickets and tried switching away from the lambda and coming back (suggested in other seemingly relevant tickets). Thanks for any help you can offer.

Is it just linting as undefined, or it is actually writing as undefined when you run it?

1 Like

I just end up with an empty object for each item.

Also, seeing this more specific message when I click. On mouse over it just says "value not defined" but getting this when I click into the field.

Hey @rodeo_mike! If you select getCustomers as the query for the 'Loop Input', does this work for you?

2 Likes

Oh weird that I didn't include that this time. Nice catch!

That said, no, same result.

I can access getCustomers.data but since would expect that I'd need to pass in getCustomers.data[index] but index isn't defined.

@rodeo_mike, is your second workflow getting called with any data? Despite the linting error, this should be working.

The linting for the value.id not being defined is somewhat expected. When the block is not being run (ie while we are looking at it, editing it etc) value doesn't exist. It's a relatively common linting error in Retool that we are looking into. When the lambda is run though, 'value' is in context and has a value.

This is confirmed when I call a second workflow with and simply console.log the data passed into the startTrigger.

  1. Initial workflow, SQL query + Loop (note linting error)

  1. Subsequent Workflow (logging start trigger data)

Note that the id is passed into this workflow and logged.

  1. The return (data) value of the Loop block is also expected, as the 2nd workflow does not have a return block.

Let me know if you have any other questions, or the second workflow is not being passed the appropriate data.