# Set node config values as \`undefined\`

**URL:** <https://discourse.nodered.org/t/set-node-config-values-as-undefined/69781>\
**Category:** General\
**Created:** [29 October 2022 20:59 UTC](https://discourse.nodered.org/t/set-node-config-values-as-undefined/69781 "2022-10-29T20:59:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [29 October 2022 20:59 UTC](https://discourse.nodered.org/t/set-node-config-values-as-undefined/69781/1 "2022-10-29T20:59:04Z")

</div>

So...  
This might be a really simple thing I am missing...

But I am migrating a node over to typescript.  
and I have a need to set a config value as `undefined` if its length is \<1...

setting `this.someConfigValue = undefined` in side `oneditsave` if it has no length does not seem to work.  
its being rendered as a 0 length string?

am I missing something?

Example:  
Printing config inside the JS file -\> `"apiKeys_firmwareUpdateService":""`

---

<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:** [29 October 2022 23:18 UTC](https://discourse.nodered.org/t/set-node-config-values-as-undefined/69781/2 "2022-10-29T23:18:18Z")

</div>

Hard to say without seeing the src. Is there a repo on GitHub or somewhere else?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [30 October 2022 08:10 UTC](https://discourse.nodered.org/t/set-node-config-values-as-undefined/69781/3 "2022-10-30T08:10:01Z")

</div>

Morning @Steve-Mcl  
I think I have narrowed it down.

When I do this:

```auto
const runtimeNodeSettings = {
    category: 'config',
    defaults: {
        security_S0_Legacy: {
            value: undefined,
            required: false
        }
    },
    oneditsave: cleanValues
}

RED.nodes.registerType('zwavejs-runtime', runtimeNodeSettings);
function cleanValues() {
    this.security_S0_Legacy = undefined;
}

```

`security_S0_Legacy` is still being set to what's in the text box - an empty string ""

Doing this however:

```auto
const runtimeNodeSettings = {
    category: 'config',
    defaults: {
        security_S0_Legacy: {
            value: undefined,
            required: false
        }
    },
    oneditsave: cleanValues
}
RED.nodes.registerType('zwavejs-runtime', runtimeNodeSettings);

function cleanValues() {
    this.security_S0_Legacy = undefined;
    $('#node-config-input-security_S0_Legacy').remove(); /* <---- This */
}

```

It does take affect. I was assuming `oneditsave` is after the values being fetched from the inputs,  
but seems to be before.

I remove the element to stop it being set to an empty string at the end of the pipeline.

I only need to do this if the string length is \< 1 but above was just a demo sketch describing the "problem"

---

<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:** [30 October 2022 08:16 UTC](https://discourse.nodered.org/t/set-node-config-values-as-undefined/69781/4 "2022-10-30T08:16:53Z")

</div>

You might be better off disassociating the variable from the form. What I mean by this is instead of giving the element an ID of "node-input-xyz" you could ID the element "my-node-el-xyz".

In doing so, you would need to manually retrieve the value in oneditprepare and store the value in your defaults variable in oneditsave.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [30 October 2022 08:18 UTC](https://discourse.nodered.org/t/set-node-config-values-as-undefined/69781/5 "2022-10-30T08:18:34Z")

</div>

Agreed!

My current work around feels tacky 😅

Thanks

---

<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:** [13 November 2022 08:19 UTC](https://discourse.nodered.org/t/set-node-config-values-as-undefined/69781/6 "2022-11-13T08:19:03Z")

</div>

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