Code node not returning the expected JSON

Describe the problem/error/question

I had a functionItem node that in some n8n update does not pass the “companyNumber” property. I have rewritten the node to the Code node type, with the same behaviour.

In the following image you see supplierNumber as input, but companyNumber is gone from the output:

What is the error message (if any)?

Please share your workflow

let $var = $input.all()[0].json

return [{
  id: $node["Map parsed phone numbers to company"].json.id,
  companyNumber: $var.hasOwnProperty('CustomerNumber') ? $var.CustomerNumber : ($var.hasOwnProperty('SupplierNumber') ? $var.SupplierNumber : null),
  userDefinedFields: [{
    "name": "eAccounting UUID",
    "value": $var.Id
  }]
}];

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.222.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: Ubuntu 20.04

Hey @fl0pp - welcome to the community :tada:

I tried to reproduce this with your code and couldn’t - I’m getting the company field as expected. Can you share your workflow with some example data so we can reproduce the problem?

Here’s the workflow I quickly created to test:

1 Like