How to convert from object to array type in code node?

Describe the problem/error/question

I want to convert an object into an array using code node, but I’m having trouble because I don’t have basic JavaScript. so I want to merge the invoice line id to the invoice after it is created. but invoice line is an object. Meanwhile, 1 invoice can have several invoice lines stored in array

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

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

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:

hello @Dinia_Kurnia_Pratiwi

Why you need a Code node for it? You can use the Split Out node that is much easier to use

can split out use for object to array? i already use it to split projects from array to object before.
i want to make json like this.
before
image

after
image

You can use the Aggregate node:

that works!! thank you so much

I have merged the invoice with the invoice line. and want to update the invoice. but get an error like this. what should I add in the invoice_line_ids field?

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