Loop Over, Done branch

The Loop Over parse correctly in the loop my data (extract from CSV), but when it’s finished, in done path it executes nodes the same number than the loop path instead of 1.

Is it normal ? I’l expecting the done path to be executed only once…

Describe the problem/error/question


Share the output returned by the last node

Information on your n8n setup

n8n, self hosted, last version

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @presta_melt , the “done” output will contain the outcome of all the processing done in the loop for each item that passed through the loop. So, yes, if you processed 13 items in the loop, the done loop will contains the final result of the loop computation for each of the 13 items.

If you intended to send only one final email after processing all 13 items then configure Send Email node to run just once.

image

1 Like

OK, i see.

But i have also other “end” processes to run after the automation (delete files, etc…).

For each of the “done path” blocks, i’ll have to set execute once ? No way to limit to 1 ?

Looking at your loop, it gives me the impression that it’s connecting to something else outside the flow, another loop that’s making it go through more than the 13 times (in this case, of course) and forcing it to pass through ‘done’ all those times… Could you show more parts of the loops?

Yep, you’r right…

But there are many nodes inside the loop…

Holy cow, haha! Two things:

  1. In the first picture, decide if the action is “Do Nothing” or “Send Email.” If it’s “Send Email,” create a separate loop for those items. Once the loop finishes, it should switch to “Do Nothing.” For items marked as “Do Nothing,” they should remain untouched—just create a “Do Nothing” node for each loop as needed.
  2. If you’re aiming to send one single email once everything is done, I’d suggest using a node to call another workflow. In this new workflow, you can handle sending the single email. It’s similar to the principles of “microservices”—let’s call it that, its easier that way, and more scalable
1 Like

Thank you,

It’s case 2. I’ll try to do what you propose :wink:

1 Like

Cool!! In n this new workflow that handles only the email-sending function, you can receive a JSON object with all those items and work with them, deciding which data to extract, like email, name, or other information. If the JSON contains a lot of data, you can use a Code node to clean up those items, merge them into one, or even filter out duplicates. You can totally do this with ChatGPT if you need help! Im imagining the email is for one person only, but you can do as you please :stuck_out_tongue:

1 Like

The “done” path always returns the number of items that were fed into the Loop node. The structure of each item returned will depend on the actual processing applied to the item. But the number of items at the output is the same as in the input.

2 Likes

OK, I add a limit 1 node after the Done Branch and now it’s ok :wink:

1 Like

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