Custom methods#
n8n provides the following methods:
$evaluateExpression: evaluates a string as an expression.$items: returns items from a given node$item: returns an item at a given index$jmespath(): perform a search on a JSON object using JMESPath.$node: data from a specified node
$evaluateExpression(expression: string, itemIndex: number)#
Evaluates a given string as expression.
If no itemIndex is provided it uses by default in the Function-Node the data of item 0 and
in the Function Item-Node the data of the current item.
Example:
1 2 3 4 | |
$items(nodeName?: string, outputIndex?: number, runIndex?: number)#
This gives access to all the items of current or parent nodes. If no parameters are supplied, it returns all the items of the current node. If a node-name is given, it returns the items the node output on its first output (index: 0, most nodes only have one output, exceptions are IF and Switch-Node) on its last run.
Example:
1 2 3 4 5 6 7 8 9 10 11 | |
$item(index: number, runIndex?: number)#
This method allows you to return an item at a specific index. The index is zero-based. Hence, $item(0) will return the first item, $item(1) the second one, and so on. Refer to this documentation to learn more.
Example:
1 2 3 4 5 | |
Refer to this example workflow to learn how this method can be used.
$node#
Returns the data of a specified node. Similar to $item, with the difference that it always returns the data of the first output and the last run of the node.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |