# How to execute "last will" command before a configuration node get removed

**URL:** <https://discourse.nodered.org/t/how-to-execute-last-will-command-before-a-configuration-node-get-removed/52442>\
**Category:** Developing Nodes\
**Created:** [19 October 2021 23:49 UTC](https://discourse.nodered.org/t/how-to-execute-last-will-command-before-a-configuration-node-get-removed/52442 "2021-10-19T23:49:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![antoine-em](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/antoine-em/32/36364_2.png) [@antoine-em](https://discourse.nodered.org/u/antoine-em)\
**Post date:** [19 October 2021 23:49 UTC](https://discourse.nodered.org/t/how-to-execute-last-will-command-before-a-configuration-node-get-removed/52442/1 "2021-10-19T23:49:00Z")

</div>

On a standard node the `this.on("close",function)` can be executed when the node is removed and/or stopped.

But for the configuration nodes how to to execute such function before the config. node get deleted ?

In my case I have a setInterval function setup in my configuration node so I would need to clear it before the config get deleted.

Thank you for your guidance.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 October 2021 00:06 UTC](https://discourse.nodered.org/t/how-to-execute-last-will-command-before-a-configuration-node-get-removed/52442/2 "2021-10-20T00:06:10Z")

</div>

Have you tried an on close function in a config node? I would have thought that it triggers as the node is deleted as well - though I've not tried it.

---

<div class="post-metadata">

**Author:** ![antoine-em](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/antoine-em/32/36364_2.png) [@antoine-em](https://discourse.nodered.org/u/antoine-em)\
**Post date:** [20 October 2021 00:16 UTC](https://discourse.nodered.org/t/how-to-execute-last-will-command-before-a-configuration-node-get-removed/52442/3 "2021-10-20T00:16:00Z")

</div>

Indeed ! thank you very much. I realized trying it again that I was not defining it in the right section block..  
So it is working as expected in the standard nodes.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 October 2021 00:55 UTC](https://discourse.nodered.org/t/how-to-execute-last-will-command-before-a-configuration-node-get-removed/52442/4 "2021-10-20T00:55:06Z")

</div>

> [@antoine-em](#):
>
> not defining it in the right section block

Yes, you may have seen from some of my other posts that I've completely restructured my nodes to make the different sections a lot clearer and more logical.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 November 2021 00:55 UTC](https://discourse.nodered.org/t/how-to-execute-last-will-command-before-a-configuration-node-get-removed/52442/5 "2021-11-03T00:55:52Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
