Hi n8n community,
I am building a workflow where I need to fetch exactly 600 records from an Airtable table before proceeding with the next steps. I understand that Airtable’s API allows fetching records in batches of 100 using the offset
parameter. My current approach involves:
- Initializing variables like
offset
,recordsFetched
, andallRecords
. - Using an HTTP Request node to fetch records from Airtable with the
offset
parameter. - A Code node to accumulate records across iterations and update the offset for the next request.
- An If node to stop the loop once
recordsFetched
reaches 600.
Challenges:
- Accumulating records dynamically across iterations.
- Exiting the loop with exactly 600 records and ensuring no records are lost in the process.
- Handling the issue where 5 items end up in the false branch and only 1 item in the true branch in the If node. I want all 600 records to move together to the next step after exiting the loop.
Key Requirements:
- Fetch records in batches of 100.
- Accumulate the fetched records until the total reaches 600.
- Dynamically update the
offset
for each request. - Stop the loop once the total records fetched equals or exceeds 600.
- Ensure all 600 records are available in the true branch after the loop ends, without splitting between true/false branches.
Question:
What is the most efficient way to implement this in n8n? Are there any best practices or alternative solutions to handle this scenario?
Any advice, examples, or pointers would be greatly appreciated!