Hi dear friends
In my case:
I search(lookout) a Google Sheets table and it returned for example 6 rows.
My question is that:
How can we show(save, return or …) number “6” (the number of my returned rows) for next node?
Best regards;
Hi dear friends
In my case:
I search(lookout) a Google Sheets table and it returned for example 6 rows.
My question is that:
How can we show(save, return or …) number “6” (the number of my returned rows) for next node?
Best regards;
The only (easy) way to do that right now would be to have additionally one column with a unique value that you can then use as “key” when you do the update. Something like an ID.
Oh I’m so sorry.
I think I explained my mind so bad.
How can my workflow realize the number of returned rows is for example 6 not 4.
For example: If I have 6 rows then go to a and if I have 4 rows go to b.
Ah sorry now I understand. You want simply get the number of results/items a node returns. Sadly is that really not possible right now in an expression directly. Will add it to the To-Do List.
For now you can do that with the help of a Function-Node like this:
Thanks for your response, you are the best.
My problem is that when number of returned rows is 0 (or it return nothing) the function node return nothing while I expect it return 0.
Best regards;
It will always returns something when there is not result it will return this [ { json: {} } ]. Something like this should do it.
{
"nodes": [
{
"parameters": {
"functionCode": "return [\n {\n json: {\n columns: 1,\n }\n },\n {\n json: {\n column: 2\n }\n },\n]"
},
"name": "Mock-Data",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
440,
300
]
},
{
"parameters": {
"functionCode": "if (Object.keys(items[0].json).length === 0) {\n return [\n {\n json: {\n results: 0,\n }\n }\n ]\n}\n\nreturn [\n {\n json: {\n results: items.length,\n }\n }\n];"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
680,
300
]
}
],
"connections": {
"Mock-Data": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
}
}
}
In the just released [email protected] it is now possible to add option “Continue If Empty”. If set it will keep on executing the workflow even if no result got returned. That should fix the problem you had.