Hi folks
Have a trigger node with more than one table row and want to extract only the first/ last row…
Hope someone can share an example that I can use for that.
Cheers Jakob
Hi folks
Have a trigger node with more than one table row and want to extract only the first/ last row…
Hope someone can share an example that I can use for that.
Cheers Jakob
The example below should do it if I understood well.
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"functionCode": "return [\n {\n json: {\n name: 'ricardo'\n } \n },\n {\n json: {\n name: 'carlos'\n } \n }\n]"
},
"name": "Mockup",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
520,
300
]
},
{
"parameters": {
"functionCode": "return [ { json: items[0].json } ]"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
770,
300
],
"notesInFlow": true,
"notes": "Pick first"
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Mockup",
"type": "main",
"index": 0
}
]
]
},
"Mockup": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
}
}
}
yeah is cool! Thank you. How can I get the last instead of the first row? Is this also possible?
This should work:
return [{ json: items[items.length - 1].json }];
The node JSON:
Hey cool, works! Thank you guys!