# IF node following a Failed node

**URL:** <https://community.n8n.io/t/if-node-following-a-failed-node/3994>\
**Category:** Questions\
**Created:** [January 26, 2021, 7:35am UTC](https://community.n8n.io/t/if-node-following-a-failed-node/3994 "2021-01-26T07:35:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ayali/32/3186_2.png) [@ayali](https://community.n8n.io/u/ayali)\
**Post date:** [January 26, 2021, 7:35am UTC](https://community.n8n.io/t/if-node-following-a-failed-node/3994/1 "2021-01-26T07:35:26Z")

</div>

I’d like to split my execution into two separate paths according to a status of a node, whether it failed on not. Note that I selected “Continue On Fail:” on that node so that execution doesn’t break.

The idea is to add an IF node following the one I’m interrogating and split the execution path from there.

My question - within the IF node, how can I query the status of the previous node (Failed, Passed)?

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [January 26, 2021, 8:09am UTC](https://community.n8n.io/t/if-node-following-a-failed-node/3994/2 "2021-01-26T08:09:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ayali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ayali/32/3186_2.png) [@ayali](https://community.n8n.io/u/ayali)\
**Post date:** [January 26, 2021, 9:49am UTC](https://community.n8n.io/t/if-node-following-a-failed-node/3994/3 "2021-01-26T09:49:25Z")

</div>

Thanks for your assistance.  
I’ve taken an existing Function node, so I’m not sure I can easily change its code, as you suggested.

I’m actually looking now at the Error Trigger node, but with this case it seems that I’m losing all data captured by the nodes in the failed workflow.

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [January 26, 2021, 9:55am UTC](https://community.n8n.io/t/if-node-following-a-failed-node/3994/4 "2021-01-26T09:55:46Z")

</div>

The workflow that I share was an example. You will have to modify it as per your use-case. The [Error Trigger](https://docs.n8n.io/nodes/n8n-nodes-base.errorTrigger/) node only gets the information about the workflow and the node that caused the error. It won’t get the data from the workflows.

---

<div class="post-metadata">

**Author:** ![ayali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ayali/32/3186_2.png) [@ayali](https://community.n8n.io/u/ayali)\
**Post date:** [January 26, 2021, 10:04am UTC](https://community.n8n.io/t/if-node-following-a-failed-node/3994/5 "2021-01-26T10:04:11Z")

</div>

Thank you. Indeed works well!
