How to group by an array by several fields

Describe the problem/error/question

Hello!
I stuck in a transformation related grouping an array according some fields.
I tried with Summary Node and split out node, but it doesn’t work, so I guess should be done with some Javascript.
At the end I want to produce a result something like this:

[
{
“code”: “BPBLST049”,
data:
{
“status”: “Sent”,
“product_title”: “Sport Thong - Punch”,
“body_html”: “Composición: 68% algodón, 26% poliéster, 6% elastano.
Hecho en México.
Algodón 100% mexicano.”,
“vendor”: “Babylon”,
“product_type”: “Tangas”,
“option_id”: 1,
“tags”: “Tanga,Nuevo,ABR24,Activo”,
“images”: “https://cdn.shopify.com/s/files/1/0469/8908/2785/files/MARCOWEB_3_49717a05-c51b-4d3b-89ef-f15f230b465e.png?v=1712349112
}
},
{
“code”: “BPBLST048”,
data:
{
“status”: “Sent”,
“product_title”: “Sport Thong - Punch”,
“body_html”: “Composición: 68% algodón, 26% poliéster, 6% elastano.
Hecho en México.
Algodón 100% mexicano.”,
“vendor”: “Babylon”,
“product_type”: “Tangas”,
“option_id”: 1,
“tags”: “Tanga,Nuevo,ABR24,Activo”,
“images”: “https://cdn.shopify.com/s/files/1/0469/8908/2785/files/MARCOWEB_3_49717a05-c51b-4d3b-89ef-f15f230b465e.png?v=1712349112
}
}
]

The last node produce 4 records but I want to transform to 2 records, since the most of the fields are the same.
In this case I want to group by code field, how I can groupby to more fields, for example code, status, product_title?

What is the error message (if any)?

There’s no error message

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

[
{
“status”: “Sent”,
“code”: “BPBLST049”,
“product_title”: “Sport Thong - Punch”,
“body_html”: “Composición: 68% algodón, 26% poliéster, 6% elastano.
Hecho en México.
Algodón 100% mexicano.”,
“vendor”: “Babylon”,
“product_type”: “Tangas”,
“option_id”: 1,
“tags”: “Tanga,Nuevo,ABR24,Activo”,
“images”: “https://cdn.shopify.com/s/files/1/0469/8908/2785/files/MARCOWEB_3_49717a05-c51b-4d3b-89ef-f15f230b465e.png?v=1712349112
},
{
“status”: “Sent”,
“code”: “BPBLST049”,
“product_title”: “Sport Thong - Punch”,
“body_html”: “Composición: 68% algodón, 26% poliéster, 6% elastano.
Hecho en México.
Algodón 100% mexicano.”,
“vendor”: “Babylon”,
“product_type”: “Tangas”,
“option_id”: 1,
“tags”: “Tanga,Nuevo,ABR24,Activo”,
“images”: “https://cdn.shopify.com/s/files/1/0469/8908/2785/files/MARCOWEB_3_49717a05-c51b-4d3b-89ef-f15f230b465e.png?v=1712349112
},
{
“status”: “Sent”,
“code”: “BPBLST048”,
“product_title”: “Sport Thong - Punch”,
“body_html”: “Composición: 68% algodón, 26% poliéster, 6% elastano.
Hecho en México.
Algodón 100% mexicano.”,
“vendor”: “Babylon”,
“product_type”: “Tangas”,
“option_id”: 1,
“tags”: “Tanga,Nuevo,ABR24,Activo”,
“images”: “https://cdn.shopify.com/s/files/1/0469/8908/2785/files/MARCOWEB_3_49717a05-c51b-4d3b-89ef-f15f230b465e.png?v=1712349112
},
{
“status”: “Sent”,
“code”: “BPBLST048”,
“product_title”: “Sport Thong - Punch”,
“body_html”: “Composición: 68% algodón, 26% poliéster, 6% elastano.
Hecho en México.
Algodón 100% mexicano.”,
“vendor”: “Babylon”,
“product_type”: “Tangas”,
“option_id”: 1,
“tags”: “Tanga,Nuevo,ABR24,Activo”,
“images”: “https://cdn.shopify.com/s/files/1/0469/8908/2785/files/MARCOWEB_3_49717a05-c51b-4d3b-89ef-f15f230b465e.png?v=1712349112
}
]

Information on your n8n setup

  • n8n version: 1.31.1
  • Database (default: SQLite): NA
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: Chrome, Windows 11 Pro

@ingeniux , something like this if you prefer no-code?

2 Likes

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