Simple question - regarding iterating through data in a node which would be processed by the next node

Hello - wondering if you the experts can help me solve what I think is a basic problem regarding iteration.

I am building a simple automation that with 4 components:

  1. Fetch approved clients from MySQL database
  2. Fetch all leads from MySQL database (with clientid)
  3. Create an excel report for each client from the leads data (by clientid) each client has certain leads attributed to them
  4. Email each client their specific report

I have built the flow for this, but I am noticing that the Get Leads by clientid node and then Generate Leads report node are not executing muliple times for the total number of records received by the Get Leads by clientid module.

Being an Integromat expert user who is trying to transition to n8n, this is confusing me. Can someone help? In Integromat, I would create an iterator process between Get Leads by clientid and Generate Leads report nodes. The iterator would cycle through all records received by the Get Leads by clientid node and then send each cycles date to the Generate Leads report node. The Generate Leads report node would then send each cycles data to the next node in the workflow.

Can some one please help with this? I went back to Integromat and built my EXACT workflow in about 7 minutes and it worked as expected.

Here is my integromat flow.
(1) First node returns 1 bundle containing 6 collections; this data is passed to second node
(2) Second and third node automatically iterate through the 6 collections based on a filter critera set within the query in node 2
(3) Node 3 will create 6 CSV files from the 6 bundles of data from node 1 → 2
(4) Node 4 is sending 4 emails because only 4 of the 6 actually contained data.

Hi @Michael_Barnett, welcome to the community :tada:

This can be confusing indeed. While most n8n nodes will run for each item they receive, database nodes are an exception to this rule.

In such cases you can use the Split In Batches node and then loop through your items one by one. Like so for example:

Hope this helps! Let me know if you have any questions on this :slight_smile:

Hi Tom,

I still cannot figure this out - check here

I created a short video.

Hi - any ideas?

Hi @Michael_Barnett, the error shown in your video around the 1:46 mark suggests a problem with your SQL query. So you might need to check what exactly is wrong with the query.

As for your expressions you might want to avoid referencing data from outside of the loop itself which can get tricky. So you might want to work with the incoming data on your MySQL node (something like $json.referralsourcesid rather than $node["Node from outside the loop"]...).

If you’re still having trouble it’d be great if you could provide a simplified workflow and database table using which your problem can be reproduced.

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