How to Count Items Within a Loop

I have a workflow that processes batch content from the OpenAI API. It follows these steps:

  1. Retrieves batch data.
  2. Checks if each request is completed.
  3. Inserts completed items into NocoDB.
  4. Once all items are inserted, it updates the table description to "All batch completed".
  5. When relaunching, the workflow checks if "All batch completed" exists to prevent reprocessing.

Issue:
If some batches are incomplete, they get skipped (which is fine), but the workflow still updates the table as "All batch completed". This prevents the incomplete batches from being processed when the workflow runs again.

What I Need:

I want to modify the logic so that the table description is only updated when all batches are truly completed. Specifically, if the total requested items ≠ completed items, it should not update the table description.

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:

You can use {{ $runIndex }}:

2 Likes

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