Workflow index - what am I doing wrong?

Hi All:

I am using a loop block within retool workflows. I am having trouble utilizing the index within the loop block and am wondering if I am doing something wrong or if it is a bug?

For example:

return index // returns the appropriate index of the loop - in this case 0
return['0'].SONO // returns the data properly
return[index].SONO // returns null even though index value is 0
return[{{index}}].SONO // tried this too but don't think {{}} are needed

// tried just storing index to another variable
var myIndex = index;
return myIndex // returns null

I am new to programming JavaScript, so it is most likely I am making a stupid mistake.

It's not a stupid mistake... can you post your entire block of code so the forum can see where the possible error exists?

Here is a screen shot. Essentially I am trying to reference the data in the previous loop so that I can use the data in the email I am sending. I thought I'd be able to pass index into the query9 to reference the data - but can't use index anywhere other than "return index"

I don't see where in query9 you are getting an index value. You're only getting the data.renderId, and that is only one value so shouldn't the index always be 0? Also, index may be a reserved word and so that could also be an issue. Where is the loop?

This is in workflows - the loop is a feature which provides an index and value variable. return index works but I can't seem to get anything else to work

Seems like a bug to me
@Kabirdas ? Thoughts?

Yep! Looks like this is actually a known issue, thanks for the callout @ScottR!

Can you try using


instead of



We can let you know here when the behavior has been fixed :slightly_smiling_face:

1 Like

Thanks, everyone! Appreciate it!

[quote="Kabirdas, post:7, topic:15412"] @ScottR @Kabirdas

hi, i am running into same issue, any idea if this was resolved ? if not, can you provide the right syntax ? tried following per post, but is not working.

Hey @Venus!

The issue hasn't been resolved yet, sorry! For the workaround, it's important to use backticks instead of single quotes because it designates a template literal. Definitely something that's easy to miss, thanks for surfacing it and let me know if that works :slightly_smiling_face:

that worked, thanks for your quick response