# Dynamic List Configuration

**URL:** <https://discourse.nodered.org/t/dynamic-list-configuration/7027>\
**Category:** General\
**Created:** [19 January 2019 19:45 UTC](https://discourse.nodered.org/t/dynamic-list-configuration/7027 "2019-01-19T19:45:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bertmartin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bertmartin/32/6355_2.png) [@bertmartin](https://discourse.nodered.org/u/bertmartin)\
**Post date:** [19 January 2019 19:45 UTC](https://discourse.nodered.org/t/dynamic-list-configuration/7027/1 "2019-01-19T19:45:21Z")

</div>

I am building my first custom module and in my configuration file I need to have a drop down list of files in a directory. I've got the basic dynamic build of the list working (thanks to the serial port module).

Everything works if I comment out these lines:

```
			fs.readdirSync(testFolder).forEach(file => {
					console.log(file);
			})

```

But uncommented my drop down doesn't show up - seems to fail on this line and therefore stops executing code.

What am i missing?

```
oneditprepare: function() {
		blist = buildlist(".");

		var vswitch = "custom";
		for (var i in blist) {
			if (this.switches == blist[i].value) {
				vswitch = this.switches;
			}
		}
		$("#node-config-input-switches").typedInput({
			default: this.switches,
			types:blist
		});   
		
	}, //end of on edit prepare

	oneditsave: function() {
	    var mytype = $("#node-config-input-switches").typedInput('type');
		$("#node-config-input-switches").typedInput('value',mytype);
		this.switches = $("#node-config-input-switches").typedInput('value');
	} //end of on edit save

```

});

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 January 2019 19:55 UTC](https://discourse.nodered.org/t/dynamic-list-configuration/7027/2 "2019-01-19T19:55:12Z")

</div>

Fs is a server side (nodejs) call. The config window is in your browser. Slight disconnect there.

You need to make an (Ajax) request from browser to the backend? Read the files there, then return the list to the browser.

---

<div class="post-metadata">

**Author:** ![bertmartin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bertmartin/32/6355_2.png) [@bertmartin](https://discourse.nodered.org/u/bertmartin)\
**Post date:** [19 January 2019 21:42 UTC](https://discourse.nodered.org/t/dynamic-list-configuration/7027/3 "2019-01-19T21:42:46Z")

</div>

Of course - that makes total sense.

Any tips or examples of how to do this? I have been googling around but have not found anything helpful yet.

Thanks for the help.

---

<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:** [19 January 2019 21:45 UTC](https://discourse.nodered.org/t/dynamic-list-configuration/7027/4 "2019-01-19T21:45:38Z")

</div>

Hi @bertmartin

this StackOverflow answer covers the basic approach for creating a custom admin endpoint in the runtime that your edit dialog can call to get data from the runtime side - [https://stackoverflow.com/questions/41567175/send-data-on-configuration/41567832#41567832](https://stackoverflow.com/questions/41567175/send-data-on-configuration/41567832#41567832)
