Split Out Items (Item Lists) not working on Function node data

I found out that the Split Out Items operations doesn’t work on Function-generated data. “Coudn’t find the field…”

I compared it with the Customer datastore node, aggregating it and then splitting out without any problem.
Completely udentical data from the Function node fails. You can check it out. The top branch works, the bottom one doesn’t

{
  "name": "Item Lists Node",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        280,
        90
      ]
    },
    {
      "parameters": {
        "operation": "getAllPeople",
        "limit": 2
      },
      "name": "Customer Datastore",
      "type": "n8n-nodes-base.n8nTrainingCustomerDatastore",
      "typeVersion": 1,
      "position": [
        500,
        90
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {json: {\n    name: ['Jay Gatsby', 'José Arcadio Buendía']\n    }\n  },\n  {json: {\n    email: ['[email protected]', '[email protected]']\n    }\n  },\n];"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        510,
        310
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "name",
        "options": {}
      },
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        910,
        90
      ]
    },
    {
      "parameters": {
        "operation": "aggregateItems",
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "name"
            },
            {
              "fieldToAggregate": "email"
            }
          ]
        },
        "options": {}
      },
      "name": "Item Lists1",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        700,
        90
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "name",
        "options": {}
      },
      "name": "Item Lists2",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        910,
        310
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Customer Datastore",
            "type": "main",
            "index": 0
          },
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Item Lists2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Customer Datastore": {
      "main": [
        [
          {
            "node": "Item Lists1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists1": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": 25
}

If the data a node does output is identical, then n8n will to 100% behave the same as it does not care, or even know about the node-type which does output the data.

In your case is the data very different.

The Item Lists1 has a “name” property for all items (in this case one item):

The Function Node has the “name” property only for the first item and not the second (for that reason the error message. There is one item with just “name” property and a second item with just an “email” item):

So you would have to change your Function Node to only return one item with both properties set.

The Function Node could would then look like this:

return [
  {
    json: {
      name: ['Jay Gatsby', 'José Arcadio Buendía'],
      email: ['[email protected]', '[email protected]']
    }
  },
];

Hope that is helpful!

1 Like

To my shame, I was confused. Thank you for pointing out my mistake.

No problem. Writing custom items in a Function-Node is honestly neither the simplest, best documented, or most intuitive thing :wink:

Happy to hear that it was helpful Have fun!

1 Like