Loop through items and invoke exec node on each

Hi,

I have a set node in the workflow that returns more than 1 item. I need an execute node to iterate through this list of items and run a script. I am not able to figure out how to create the loop.

Below is a screenshot of the list of items from the set node. I need to iterate through this list and run the execute node on the value of “queryString”.

Can you help please?

Hey @ronykris,

Normally the nodes will loop anyway so if you have had 5 results coming out of one node the next node would also run 5 times once for each input, if you wanted a bit more control through take a look at the Split in Batches node.

2 Likes

I think this is exactly what I was looking for @jon. I’ll play around with it and revert. Thank you for the quick response.

As @jon mentioned, your exec node should execute as many times as there are data items coming into it, so you shouldn’t need the split in batches node.

More info on looping here: Looping in n8n | Docs

3 Likes

Thank you for the documentation. I will go through these and fix the workflow.

1 Like