When I use a function node to return items[0] I get no results but when i use items.reverse() it works so I am ensuring it is an array. How can I apply filter and only pass selected items to next node ? And how can i choose only the first item to be sent to the next node?
Great! I have it on my to-do list since a long time to create documentation for the Function-Nodes. Until they are in place problems like that are sadly to expect.
Accessing previous nodes is possible already. Do sadly not remember the exact syntax right now. Think was something like node("name") but have to check once I am in front of my computer again. Will then write you.
Multiple inputs are not possible yet. But for that you can simply use a Merge-Node in “pass through” in combination with the syntax I write you later.
Ok could check now. It is possible like that in the Function-Node:
// $node returns always the data of the first item
items[0].json.nodeVariable = $node["Init Data"].data["myNumber"];
items[1].json.nodeVariable = $node["Init Data"].data["myNumber"];
items[2].json.nodeVariable = $node["Init Data"].data["myNumber"];
// $item allows to access the data of the item with the given index
items[0].json.itemVariable = $item(0).$node["Init Data"].data["myNumber"];
items[1].json.itemVariable = $item(1).$node["Init Data"].data["myNumber"];
items[2].json.itemVariable = $item(2).$node["Init Data"].data["myNumber"];
return items;
Here in a workflow to make that a little bit clearer: