HowTo ? For loop on function node for multiple items

I have the following workflow:

my mysql query returns multiple items and i would like to run the function node for each item that is passed through and then carry the random number over to the wait node which in turn will trigger another mysql query.

My javascript is basically copy /paste from the web or getting help over here.

Hi @Surge.Media, so you’d like your Function node to run for all incoming items? You could simply use the basic looping template that is part of the Function node when you freshly add it. So something like

for (item of items) {
  item.json.RandomNumber = Math.floor(Math.random() * 540);

return items;

Thanks @MutedJam for the quick response and exact code that I needed!

1 Like