Custom Node Help: Convert Fixed Collection Data to API-Compatible Format

Help with Fixed Collection Data Transformation in Declarative Style

Hi everyone,

I’m currently developing a custom node in the declarative style, as recommended, but I’m struggling with transforming data so that my API endpoint receives it in the expected format.

I have a Fixed Collection like this:

{
    displayName: 'Item Test',
    name: 'itemTest',
    placeholder: 'Add Item Test',
    type: 'fixedCollection',
    default: '',
    typeOptions: {
        multipleValues: true,
    },
    options: [
        {
            name: 'itemValues',
            displayName: 'Item',
            values: [
                {
                    displayName: 'Name',
                    name: 'name',
                    type: 'string',
                    default: 'Name of the Item',
                },
                {
                    displayName: 'Quantity',
                    name: 'quantity',
                    type: 'number',
                    default: '',
                    description: 'Item quantity',
                },
            ],
        },
    ],
}

With this setup, the node output looks like this:

{
  "itemTest": {
    "itemValues": [
      { "name": "Item 1", "quantity": 1 },
      { "name": "Item 2", "quantity": 2 }
    ]
  }
}

However, my API expects the data in this format:

{
  "items": [
    { "name": "Item 1", "quantity": 1 },
    { "name": "Item 2", "quantity": 2 }
  ]
}

Is there a way to transform the structure in declarative mode, or do I need to switch to programmatic mode? Any help or best practices would be greatly appreciated!

Thanks! :blush:


This post was written with the help of AI to improve clarity, as English is not my native language.

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 @paulkolle

Can’t say for the syntax ( I’m using the programmatic style in community nodes), but check the resource mapper type.
Node UI elements | n8n Docs

1 Like