How to nested split in batches?

Describe the issue/error/question

Hi, im trying to nest two split in batches, because i have the following workflow (reorder computer on Active Directory OU’s based on computer name patterns) steps:

  • Retrieve from Google Sheets a table (column 1: pattern, column 2: destination OU)
  • Per each row
    ** Retrieve all computers using LDAP node in my Active Directory all computers that have a matching pattern in the computer name.
    ** Per each retrieved computer from Active Directory:
    *** If actual organizational units (distinguishedName) doesnt end in the actual column 2 (destination OU) of Google Sheet: move computer to “destination OU of Google sheets” else, do nothing.

What is the error message (if any)?

I cant get the workflow to work properly, all the rows from google sheets gets compared with alls results from LDAP (i want a normal nested behaviour to happen as in a programming language).

Please share the workflow

Because the workflow uses n8n-nodes-ldap, I share the actual filter search in LDAP:

(&(objectClass=computer)(name={{ $json["Nomenclatura"] }}))

Share the output returned by the last node

Information on your n8n setup

  • n8n version: last (queue mode)
  • Database you’re using (default: SQLite): postgresq
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm,, desktop app]: Docker, k8s

Please, know that the “Code node” is there only for debugging purposes.

Hi @German_Bravo

Welcome to the community!

This cannot properly be done without using a subworkflow where you do the nested split in batches. This because a split in batches node will remember the batch values of the previous run. There should be some examples on the forum if you want to know more about sub workflows.
It is basically a workflow that you trigger with the “execute workflow” node.

1 Like

Hi @BramKn , thanks!

Isnt it possible to achieve the nested split in batches using the Reset parameter pointing to noLeftItems context var?

I could find an alternative solution using just one split in batches and some aggregation, spliting of array, with a set node.

1 Like

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