# Dinamycally changing true - false

**URL:** https://discourse.nodered.org/t/dinamycally-changing-true-false/45421
**Category:** General
**Created:** [10 May 2021 09:22 UTC](https://discourse.nodered.org/t/dinamycally-changing-true-false/45421 "2021-05-10T09:22:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jake123](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@jake123](https://discourse.nodered.org/u/jake123)
#### Post date: [10 May 2021 09:22 UTC](https://discourse.nodered.org/t/dinamycally-changing-true-false/45421/1 "2021-05-10T09:22:16Z")

</div>

I have a default config parameter `isTrue: {value:""}`  
On the start of my `oneditprepare` function i set `if(node.isTrue) {node.isTrue = !node.isTrue}`  
On the end of my `oneditsave` function i set it `if(node.isTrue){node.isTrue = !node.isTrue}`

So basically i want when the node is opened isTrue to be set to true and when its closed i want to make it false.  
The problem i get is that when i do this it changes the value only 1st time 1 open the node. Second time i open it it doesnt change the value `oneditsave`  
Any idea why?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [10 May 2021 09:28 UTC](https://discourse.nodered.org/t/dinamycally-changing-true-false/45421/2 "2021-05-10T09:28:52Z")

</div>

> [@jake123](#):
>
> So basically i want when the node is opened isTrue to be set to true and when its closed i want to make it false

If you want it to be false oneditsave, just set it false

```auto
node.isTrue = false;

```

If you want it to toggled oneditsave, just remove the `if` line

```auto
node.isTrue = !node.isTrue;

```

The question I have is why?

---

<div class="post-metadata">

### Author: ![jake123](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@jake123](https://discourse.nodered.org/u/jake123)
#### Post date: [10 May 2021 09:29 UTC](https://discourse.nodered.org/t/dinamycally-changing-true-false/45421/3 "2021-05-10T09:29:44Z")

</div>

I managed to do it yea. Because some websocket functions i have in my node is constantly calling even if i close the node. This way i managed to make it not call the function when the node is closed.  
If i try to disable them then i get some other errors that i dont know how to fix. This way it works fine.  
Only 1 problem is that i have to click 2 times on the button to unsubscribe the element.

---

<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: [9 July 2021 09:30 UTC](https://discourse.nodered.org/t/dinamycally-changing-true-false/45421/4 "2021-07-09T09:30:10Z")

</div>

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