# Default config node

**URL:** <https://discourse.nodered.org/t/default-config-node/46773>\
**Category:** Developing Nodes\
**Created:** [6 June 2021 13:12 UTC](https://discourse.nodered.org/t/default-config-node/46773 "2021-06-06T13:12:29Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [6 June 2021 13:12 UTC](https://discourse.nodered.org/t/default-config-node/46773/1 "2021-06-06T13:12:30Z")

</div>

Hi folks,

When you create a config node for the [node-red-node-dropbox](https://flows.nodered.org/node/node-red-node-dropbox) node, then that _**config node is automatically selected (in the config dropdown) when a new dropbox node is added**_ to the flow.

I would like to achieve the same behaviour for one of my own nodes, but I can't find how this is implemented in the [dropbox.html](https://github.com/node-red/node-red-web-nodes/blob/master/dropbox/dropbox.html) file. Thought perhaps that the `required:true` would have that as a side-effect, but it doesn't work for my node so it must be something else doing the magic.

Moreover, I don't want the config to become required ...

Hopefully anybody can enlighten me.  
Thanks!  
Bart

---

<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:** [6 June 2021 13:21 UTC](https://discourse.nodered.org/t/default-config-node/46773/2 "2021-06-06T13:21:13Z")

</div>

> [@BartButenaers](#):
>
> Moreover, I don't want the config to become required ...

set it to `required:false`

here is an example: [node-red-contrib-ngrok/ngrok.html at cd02a2431f97832f6f8552480ce941c87a845f57 · sammachin/node-red-contrib-ngrok · GitHub](https://github.com/sammachin/node-red-contrib-ngrok/blob/cd02a2431f97832f6f8552480ce941c87a845f57/ngrok.html#L11)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [6 June 2021 13:33 UTC](https://discourse.nodered.org/t/default-config-node/46773/3 "2021-06-06T13:33:53Z")

</div>

Hey Steve,  
Thanks!  
Yes indeed I had already ´required:false´ in my node, but I was looking how the dropbox node automatically assigns a config node. The only difference with my node was that the dropbox node has ´required:true´, so I thought that it perhaps was done that way.  
But even setting it to true (which I don't want...) doesn't automatically select the config node in my case. So not sure how to achieve it ...

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [7 June 2021 20:19 UTC](https://discourse.nodered.org/t/default-config-node/46773/4 "2021-06-07T20:19:11Z")

</div>

Still not sure how to continue with this...

Suppose I have N config nodes created for my custom node. As soon as I drop a new instance of my custom node on my flow, then I want to link the first available config node to my new custom node. From this old [discussion](https://groups.google.com/g/node-red/c/LfQ8hV-tjME/m/8LMpu-T0AwAJ), I assume that I cannot get a list of the available config nodes (of a particular type)?

Or can I do it another way perhaps? I still don't understand how e.g. the dropbox node selects automatically a config node. Would be nice if somebody could enlighten this piece of magic!!!

---

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [7 June 2021 23:35 UTC](https://discourse.nodered.org/t/default-config-node/46773/5 "2021-06-07T23:35:11Z")

</div>

Hey,

Take also a look into the js file!  
Line 40 and 54 looks promising.  
Sorry that i can't help you more but i am currently with my phone on.

Greetings

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [8 June 2021 11:48 UTC](https://discourse.nodered.org/t/default-config-node/46773/6 "2021-06-08T11:48:39Z")

</div>

Hi @H3llsing,  
Thanks a lot for your assistance!  
But I'm afraid that code won't help me. It is server side code which gets the config that has been selected previously on the frontend.  
However it is the frontend part that I'm not understanding: how is the config node automatically selected in the dropdown, as soon as a new dropbox node is being added to the flow ...

---

<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:** [8 June 2021 12:10 UTC](https://discourse.nodered.org/t/default-config-node/46773/7 "2021-06-08T12:10:50Z")

</div>

Hi @BartButenaers

there isn't anything particularly special about the Dropbox node.

As with all nodes that have a config node dependency, when you first add the node to the workspace it'll be marked with an error because its missing the config node. When you open the edit dialog, if no instances of the config node exist, the select box will be empty with the 'add new XYZ...' option selected. But if there is a suitable config node, it will be selected by default.

That's the only behaviour I can think of that you may be referring to - we automatically select the first available config node if it isn't already set.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [8 June 2021 20:34 UTC](https://discourse.nodered.org/t/default-config-node/46773/8 "2021-06-08T20:34:56Z")

</div>

> [@knolleary](#):
>
> we automatically select the first available config node if it isn't already set.

Hi @knolleary,  
That _"automatically"_ is what I don't understand how it works ...

When I use the dropbox node, it indeed behaves exactly like you describe:

1. When a drop my first node in the flow, it gets a red triangle due to a missing (required) config node:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1f77f8eb06ede45d52f7a4460a0c3eac7dc29cd4.png)

2. When I open that node, I get the option to create a new config node:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a95dc0c68465f1dbdc3391fbb68c175e34d7dc61.png)

3. I create a new config node and that becomes selected:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd4b4f1089dde6cc47b91cf9925f6b097b816453.png)

4. When I add a second node to my flow, this gets in turn a red triangle due to a missing config node:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/7039a39851afb07fe6e69a30240e2d401446312c.png)

5. When I open that second node, indeed my _**(first) config node is automatically selected**_:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/2508819079def02061cabd91bd1c3a923ddd70b8.png)

_Summarized my question is: what do I need to do to get the same magic as in step 5?_

Last week I have added a config node to the [blockly](https://github.com/bartbutenaers/node-red-contrib-blockly/blob/release-1.1.0/blockly.html#L328) node, and @cymplecy would like the config node to be selected automatically for new blockly nodes. But that doesn't happen for some reason, although I have a series of config nodes already available:

![blockly_config_select](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b8d2bc8b3d32a1ca3f4ae530e0dcc1f822eb820.gif)  
P.S. I have used `required:false`, but it also doesn't work for `required:true`.

It must be something stupid, but I don't see what I'm doing wrong...

---

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [8 June 2021 21:38 UTC](https://discourse.nodered.org/t/default-config-node/46773/9 "2021-06-08T21:38:49Z")

</div>

Hey @BartButenaers  
Have you tried to delete the default value?  
Try to replace this line

```auto
            creds: { value: "", type: "ngrokauth", required: false },

```

With this

```auto
            creds: { type: "ngrokauth", required: true },

```

Because i think the automatic selection which nick was mention can not apply when you give it an empty default value. Im think the required is only for validation and should not affect the automatism.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [8 June 2021 21:45 UTC](https://discourse.nodered.org/t/default-config-node/46773/10 "2021-06-08T21:45:21Z")

</div>

Hi @H3llsing,

I knew it must have been something stupid...  
After deleting the default value it is indeed solved.  
The first config node is automatically selected:

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

Thanks for having a look at my issue !!!!!!!!!!!!!!!!!!!!!!!!

Bart

---

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [8 June 2021 21:47 UTC](https://discourse.nodered.org/t/default-config-node/46773/11 "2021-06-08T21:47:44Z")

</div>

Im happy to help 🙂

---

<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:** [22 June 2021 21:48 UTC](https://discourse.nodered.org/t/default-config-node/46773/12 "2021-06-22T21:48:05Z")

</div>

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