Hi n8n community,
I’m encountering an issue in a workflow that involves two loops: “Loop Aluno” (Student Loop) and “Loop Cobranças” (Charges Loop). The issue seems to arise because the “Loop Cobranças” node is retaining data processed during the previous iteration of “Loop Aluno”, rather than using the correct data from the current iteration.
Same is said here: Having an issue with looping (multiple loops in one workflow) - #6 by Imperol
Problem Description
- The workflow starts with the “Loop Aluno” node, iterating over a list of students.
- Inside “Loop Aluno”, there is a second loop called “Loop Cobranças”, which processes charges associated with each student. This second loop is fed by the Split Out node.
- During the first iteration of “Loop Aluno”, “Loop Cobranças” works as expected, processing the correct data and moving to the
done
branch after all charges are processed. - However, during the second iteration of “Loop Aluno”, “Loop Cobranças” reuses the data from the first iteration instead of using the data from the Split Out node associated with the current student.
- Enabling the
reset
option on “Loop Cobranças” clears all data, but this prevents the workflow from reaching thedone
branch, which is required to complete the loop correctly.
Expected Behavior
- The “Loop Cobranças” node should only process the data sent by the Split Out node for the current iteration of “Loop Aluno”.
- When no items are left to process, “Loop Cobranças” should automatically move to the
done
branch, without reusing data from previous iterations.
Workflow Details
- “Loop Aluno” configuration:
- Type:
Split In Batches
batchSize
: Default configuration
- Type:
- “Loop Cobranças” configuration:
- Type:
Split In Batches
batchSize
: 100
- Type:
- Other nodes in the workflow:
- “Obter dados financeiros”: Fetches financial data for each student from a database.
- “Aggregate”: Aggregates the financial data.
- “Mais de 100?”: Checks if there are more than 100 items to process before splitting them.
- “Split Out”: Splits the aggregated data into batches for the “Loop Cobranças” node.
Information on your n8n setup
- n8n version: 1.57.0
- Running n8n via (Docker, npm, n8n cloud, desktop app): desktop app
- Operating system: Windows 11