# Can a custom node .html file use values from settings.js?

**URL:** <https://discourse.nodered.org/t/can-a-custom-node-html-file-use-values-from-settings-js/54468>\
**Category:** Developing Nodes\
**Created:** [29 November 2021 16:25 UTC](https://discourse.nodered.org/t/can-a-custom-node-html-file-use-values-from-settings-js/54468 "2021-11-29T16:25:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [29 November 2021 16:25 UTC](https://discourse.nodered.org/t/can-a-custom-node-html-file-use-values-from-settings-js/54468/1 "2021-11-29T16:25:15Z")

</div>

I would like to use the value of `nodeMessageBufferMaxLength` defined in `settings.js` in the edit dialog of a custom node. It is available as `RED.settings.nodeMessageBufferMaxLength` in the .js file, but I don't seem to be able to access it in the .html file.. I have tried using it in the `oneditprepare` function and in the `defaults` object, but in each case the value returned is `undefined`. Is there a reason for this, or am I making some mistake?

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [29 November 2021 17:49 UTC](https://discourse.nodered.org/t/can-a-custom-node-html-file-use-values-from-settings-js/54468/2 "2021-11-29T17:49:52Z")

</div>

No, you can't access them directly from the editor.

A sanitised copy of some of the settings are passed to the editor, but it only contains editor specific settings.

What problem are you trying to solve by having it available to the configuration dialogue?

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [29 November 2021 19:01 UTC](https://discourse.nodered.org/t/can-a-custom-node-html-file-use-values-from-settings-js/54468/3 "2021-11-29T19:01:53Z")

</div>

> [@hardillb](#):
>
> What problem are you trying to solve

Less of a problem than a feature...

My [node-red-contrib-queue-gate](https://flows.nodered.org/node/node-red-contrib-queue-gate) node allows the user to limit the number of messages in the queue. The default value is currently fixed at 100, but I would like it to be `nodeMessageBufferMaxLength` for consistency with the core nodes that honor this setting. The user could then set it as he/she likes.

---

<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:** [30 November 2021 10:55 UTC](https://discourse.nodered.org/t/can-a-custom-node-html-file-use-values-from-settings-js/54468/4 "2021-11-30T10:55:04Z")

</div>

You can pass data from the back end to the front using the settings option in registerType:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/8/7890579016ba959ef748ec0e2c3d6ab07bd10bdb.png)

The var names must start with the name of your node.

If you need anything more complex/dynamic, you need to use an API.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [30 November 2021 19:37 UTC](https://discourse.nodered.org/t/can-a-custom-node-html-file-use-values-from-settings-js/54468/5 "2021-11-30T19:37:18Z")

</div>

Thanks for that, Julian.

I remember glancing at that bit of the [documentation](https://nodered.org/docs/creating-nodes/node-js#custom-node-settings) and thinking "too clever, I'll never need that." It's exactly what I needed. 😀

---

<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:** [14 December 2021 19:37 UTC](https://discourse.nodered.org/t/can-a-custom-node-html-file-use-values-from-settings-js/54468/6 "2021-12-14T19:37:20Z")

</div>

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