# Creating Custom Config node and adding reference of that config to all normal node created

**URL:** https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399
**Category:** Developing Nodes
**Created:** [30 March 2021 12:20 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399 "2021-03-30T12:20:01Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Sudthakur](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Sudthakur](https://discourse.nodered.org/u/Sudthakur)
#### Post date: [30 March 2021 12:20 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/1 "2021-03-30T12:20:01Z")

</div>

Hi All,

I have created more than 10 nodes for different purposes, in which I am supplying the ClientId and ClientSecret to connect the API in all node. This I have achieved, but now the new requirement to put both common input in config so to input once and use in all global.

I want to create a custom config that will have ClientId and ClientSecret. which will be used in all normal custom node created. for the purpose of reusability in global context.

Please help me to achieve this.

---

<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 March 2021 16:21 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/2 "2021-03-30T16:21:47Z")

</div>

The process is documented in the Node-RED docs. You could also look at the code for one of the many nodes that use it.

I published a test node that also includes it. The test node was put together to remind me of all of the various parts of a node and is heavily documented.

> **[TotallyInformation/node-red-contrib-jktesting](https://github.com/TotallyInformation/node-red-contrib-jktesting)**
>
> Test nodes for Node-RED for learning and experimenting, best practice, lots of hints and notes

---

<div class="post-metadata">

### Author: ![Sudthakur](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Sudthakur](https://discourse.nodered.org/u/Sudthakur)
#### Post date: [1 April 2021 08:19 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/3 "2021-04-01T08:19:52Z")

</div>

Hello Sir,

I have gone through above mentioned project and implemented in my project. But I am getting invalid Properties error on node  
[invalidproprtieserror.pdf](https://discourse.nodered.org/uploads/short-url/jCaDLbFjMXN1FL1iksrEhVWpoo0.pdf) (177.6 KB)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/3/930a4e11e14ba6da85b7743f95dc4756280c4622.png) ---\> This is config node with name GetAuthentication.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/673a3b7cacb7fa1740626f34037efe66bff8cb97.png) ----\> These are all nodes where want to implement config node.

Could you please help on this.

---

<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: [1 April 2021 08:30 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/4 "2021-04-01T08:30:05Z")

</div>

I can't really tell anything from the supplied information. However, it took me several goes to get a working config node as well. There are several things you have to align for them to work. I can only suggest going back to the docs and following them very carefully, comparing against what you've done.

There is something in package.json you have to do, then specifics in both the html and js files both for the config node and in the nodes that want to use the config node.

---

<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: [1 April 2021 08:31 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/5 "2021-04-01T08:31:42Z")

</div>

Hi, can I ask, instead of all these individual nodes, have you considered having just one node with a drop down that the user selects what to get e.g. "GetAllMachines" or "GetMachineLastJob" etc etc.

This makes it easier for the user to automate operations (especially if you let the user pass in the "function" via a msg property.

e.g. the user might want to trigger your node with a msg like this...

```auto
msg.topic = "GetAllMachines"
return msg;

```

or

```auto
msg.topic = "GetMachineLastJob"
return msg;

```

---

<div class="post-metadata">

### Author: ![Sudthakur](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Sudthakur](https://discourse.nodered.org/u/Sudthakur)
#### Post date: [1 April 2021 08:37 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/6 "2021-04-01T08:37:59Z")

</div>

Thank You Sir,

I will look deeply in all files once again.

---

<div class="post-metadata">

### Author: ![Sudthakur](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Sudthakur](https://discourse.nodered.org/u/Sudthakur)
#### Post date: [1 April 2021 08:46 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/7 "2021-04-01T08:46:49Z")

</div>

Thanks for your suggestion.

Yes this also might be the solution for this. But all nodes code will have to be in one html and js file that might look bad. and changes also will be tedious job.

So put all separate nodes with there functionality, And it is the requirement also.

And I will recommend your solution also. But for now could you please help with config node, if you have a better way to achieve this. I just want to put clientId and clientSecret in config node and to access in all normal node.

Your help is much appreciated sir.

Thanks

---

<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: [1 April 2021 08:54 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/8 "2021-04-01T08:54:26Z")

</div>

You can, of course, leveage Node.js's native module support in your js file. In uibuilder, I have two external modules, one that contains non-Node-RED specific functions and the other where the functions require references to the RED object. These modules can be `require`d into multiple js files of course an d Node.js takes care of only loading them once.

---

<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: [1 April 2021 09:04 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/9 "2021-04-01T09:04:36Z")

</div>

> [@Sudthakur](#):
>
> Yes this also might be the solution for this. But all nodes code will have to be in one html and js file that might look bad. and changes also will be tedious job.

I would disagree - maintaining 10 different node is harder than 1 with a dropdown.

Also, I suspect if the request is for "separate nodes" i suspect the end user either doesn't understand the benefits they will miss out on OR the specification is unclear OR they will ask you to re-do it when they realise they cannot easily automate it.

And, as @TotallyInformation points out, the "functionality" can easily be kept in separate JS files and `require`d into your node.

---

<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: [31 May 2021 09:04 UTC](https://discourse.nodered.org/t/creating-custom-config-node-and-adding-reference-of-that-config-to-all-normal-node-created/43399/10 "2021-05-31T09:04:43Z")

</div>

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