Return the input items that produced the output items... Item Linking?

Hi @ckrkptrck

This is part of using the code node in n8n because it sort of “interrupts” the programmatic data flow of a workflow. In order to keep the data flow linked and for future nodes reference-able you need to link the items via the pairedItem property.

Like so:

return items[0].json.data.map((item, index) => {
  return { json: item, pairedItem: index };
});

If you do not link them you could potentially run into a mapping issue further down the workflow when referencing a node before the code node

Note, this only applies to using the item variable. If you’re working with $input instead, the item linking will be done by n8n under the hood.

1 Like