Looping and run whole workflow for each item one by one

Describe the issue/error/question

I’m listening a mail box, when I have multiple from IMAP Mail Node, It multiplies on Merge Nodes,

So I want to send all mails that I receive from IMAP Mail one by one and finish the flow one by one.

  • Like above picture,
  • Send first row and finish the workflow and than,
  • Send the second row and finish the workflow and than,
  • Send the third row…

make (integromat) has a feature called array iterator for this,

How can I achive this functionality in n8n?

Please share the workflow

Information on your n8n setup

  • n8n version: Last Version of Web n8n

Hi @onurbolaca

The split in batches node will do what you need. :wink:
Simply set it to batch size 1 and it will process everything one by one.

Hi Bram,

Thank you for your help!

I tried but it didn’t worked as expected,

I have 3 mails in mailbox and I receive them,

But only 1 of them saved when I use Split in Batches Node, (I could see the database records, there were only 1 new record.)

It works like getting only the first of them.

My split in batches node;

Where do I do wrong?

At the end you need to put a line back into the splitinbatches node. Otherwise It will never start on the next. :slight_smile:

If the End isn’t always the same It might be a good idea to put the workflow in another workflow as a sub workflow and then call that within the splitinbatches loop.

Your help is huge Bram, thank you so much!

So I made it work BUT

As you told it’s not always ending on the same END due to the IF condition. And when I use both conditions it doesn’t work.

Can you please give an example to this you said or detail it a bit?

… put the workflow in another workflow as a sub workflow and then call that within the splitinbatches loop.

image

Then the workflow you execute you just copy paste your entire workflow into.

Bram thank you,

I don’t understand Bram,

Where is the trigger flow on what you show here?

image

I also don’t understand lets say we have trigger flow connected with split in batches, than how am I supposed to connect them with the rest of the flow in Execute Workflow node?

I copy paste my whole flow as it is shown above with if condition as json into Execute Workflow node but it says like this;

Thank you Bram,

It looks confusing but it works.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.