Hey @ayali!
Welcome to the community!
Currently, there is no way to get the status of the previous node. However, there is a work around for it. The following workflow might help.
In the following workflow, I’ve also set the Always Output Data to true
for the Function node. If you change the code in the Function node to const items.json.myvariable...
it will give an error. The IF node will check for this. If the Function gives an error the IF node will return true otherwise false. Depending on the node that you have prior to the IF node, you may have to modify the condition in the IF node.
{
"nodes": [
{
"parameters": {},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
450,
300
],
"alwaysOutputData": true,
"continueOnFail": true
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{!!Object.keys($json).length}}"
}
]
}
},
"name": "IF",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
650,
300
]
},
{
"parameters": {},
"name": "Workflow Failed",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
850,
200
]
},
{
"parameters": {},
"name": "Workflow Success",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
850,
400
]
}
],
"connections": {
"Function": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0
}
]
]
},
"IF": {
"main": [
[
{
"node": "Workflow Failed",
"type": "main",
"index": 0
}
],
[
{
"node": "Workflow Success",
"type": "main",
"index": 0
}
]
]
}
}
}