Categories
DeepOpinion Tips and Tricks

Function Node

The Function node excels at data transformation, allowing you to manipulate information flowing between other nodes in your workflow. Whether you need to restructure data formats, perform calculations, or apply custom business logic, this node serves as your primary tool for implementing bespoke functionality.

Examples

Get property value from a previous node

for (const [index, item] of items.entries()) {
  item.json.myVar =
    $item(index).$node["node name"].json.myVar;
}
let myVar = items[0].json.myVar;

Check if the previous node returns an empty item

return [
  {
    json: {
      empty: items.length == 1 && Object.keys(items[0].json).length == 0,
    },
  },
];

Access all items from the previous node output

return $items("node name");