# Store and Restore dynamic node UI properties

**URL:** <https://discourse.nodered.org/t/store-and-restore-dynamic-node-ui-properties/66831>\
**Category:** Developing Nodes\
**Created:** [24 August 2022 05:37 UTC](https://discourse.nodered.org/t/store-and-restore-dynamic-node-ui-properties/66831 "2022-08-24T05:37:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbenson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mbenson/32/66625_2.png) [@mbenson](https://discourse.nodered.org/u/mbenson)\
**Post date:** [24 August 2022 05:37 UTC](https://discourse.nodered.org/t/store-and-restore-dynamic-node-ui-properties/66831/1 "2022-08-24T05:37:40Z")

</div>

I wrote a node that has a dropdown list property (field?) that is used to basically define the function of the Node. Some of the functions have additional properties. So I wrote the node to dynamically add the labels and input boxes for the additional properties. Basically, you see a different set of properties depending on which function you selected. When the function field changes, the div containing the html is deleted, and then recreated from the corresponding mustache template. Visually, it works perfect. The problem is my properties are not persistent.

What is the mechanism that Node Red uses to identify data it needs to persist? Something I’m doing with dynamically generating the properties is making it not persist. When I click save, close the dialog, and reopen it, my dynamic properties are back to empty. Is there anything I can do to ensure they persist? Or am I bending Node Red too far?

---

<div class="post-metadata">

**Author:** ![tve](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tve/32/59475_2.png) [@tve](https://discourse.nodered.org/u/tve)\
**Post date:** [24 August 2022 05:55 UTC](https://discourse.nodered.org/t/store-and-restore-dynamic-node-ui-properties/66831/2 "2022-08-24T05:55:40Z")

</div>

In the abstract what you're trying to do can be done. In the concrete, well... you didn't post any HTML or JS snippets, so there's nothing concrete to look at...

You need to put the values into the HTML input elements, that's where NR gets the values to stick into the fields. The input elements need to have IDs that use the naming pattern.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 August 2022 06:33 UTC](https://discourse.nodered.org/t/store-and-restore-dynamic-node-ui-properties/66831/3 "2022-08-24T06:33:10Z")

</div>

It might be safer to define them all from the start, and hide the ones you don't want when necessary. So they still exist but are not visible.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 August 2022 07:20 UTC](https://discourse.nodered.org/t/store-and-restore-dynamic-node-ui-properties/66831/4 "2022-08-24T07:20:37Z")

</div>

You must predefine all properties on the node object as described in the docs: [Node properties : Node-RED](https://nodered.org/docs/creating-nodes/properties)

This is how the editor knows what properties to include when exporting the node.

But this just applies to the top level properties of the node object itself.

If you want dynamic properties, then you could define a single top-level 'props' property as an object, and then add whatever custom properties you want under that using the `oneditprepare` and `oneditsave` functions.

You'd lose all the built-in convenience of top-level property handling such as validation and error reporting, but it would be one way to do it.

---

<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:** [24 August 2022 08:45 UTC](https://discourse.nodered.org/t/store-and-restore-dynamic-node-ui-properties/66831/5 "2022-08-24T08:45:49Z")

</div>

> [@mbenson](#):
>
> What is the mechanism that Node Red uses to identify data it needs to persist? Something I’m doing with dynamically generating the properties is making it not persist. When I click save, close the dialog, and reopen it, my dynamic properties are back to empty. Is there anything I can do to ensure they persist? Or am I bending Node Red too far?

This might help..

> [@I added input feilds dynamically then how can i save data from those inputs in the defaults](https://discourse.nodered.org/t/i-added-input-feilds-dynamically-then-how-can-i-save-data-from-those-inputs-in-the-defaults/62687/4):
>
> By the looks of it, your custom node is not using the dedicated [editableList](https://nodered.org/docs/api/ui/editableList/) I would suggest you look at the source of any of the built in nodes that have an editableList for reference. In short, you need to loop through the entries in oneditsave and store them as an object or array in the defaults. See here for more info: [Node edit dialog : Node-RED](https://nodered.org/docs/creating-nodes/edit-dialog)

---

<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:** [23 October 2022 08:46 UTC](https://discourse.nodered.org/t/store-and-restore-dynamic-node-ui-properties/66831/6 "2022-10-23T08:46:37Z")

</div>

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