Cannot access variable after spreadsheet

ERROR: No data found for item-index: "1"

FunctionItem code:

Before Read Spreadsheet raw:

After Read Spreadsheet raw:


The error message actually says what the problem is. You try to access data of the node “Get Task” but it does not have data for the item you request it from.
That node has only one single item, so index “0” and it does not have one with index “1”.

So if you connect the node after “Get Attachment” (which has presumably just one item) it is not a problem. The FunctionItem node executes one time (for that one item) and gets data of that one item from the “Get Task” node.

If you connect it to the “Attachment Spreadsheet” node (which has presumably multiple items) it fails. The reason is that the node executes once per item (therefore the name). So for the first item (index “0”) it executes for, it can get data from the “Get Task” node. If it then executes for the second item (index “1”) it can not, as no data for item with index “1” can be found, as not such item exists.

If you specifically want to get always the data of the first item of that node, you have to use $item(). So the instead of this line:

$item.myVariable = $node["Set"];

you would write the following:

$item.myVariable = $item(0).$node["Set"];
1 Like

@jan And how do I get the number of elements in an array this way? I need to count(inside the function) how many elements in $node['Spreadsheet']

$node["Spreadsheet"].json.length and $node["Spreadsheet"].json['data'].length not work

You can get all the items of a node via $items. So in your case that would be: $items('Spreadsheet').length

1 Like