# Populate input dropdown from json file

**URL:** https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217
**Category:** General
**Created:** [2 February 2021 07:50 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217 "2021-02-02T07:50:01Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [2 February 2021 07:50 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/1 "2021-02-02T07:50:02Z")

</div>

Hi,

in my subflow I have set an input variable as a dropdown select. I would like to populate the dropdown from an external json file.  
Is it possible?  
Thanks

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [2 February 2021 07:59 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/2 "2021-02-02T07:59:13Z")

</div>

You can't. These are environment variables and are evaluated/set in the runtime the moment you press deploy.

Could you explain what you are trying to do ?

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [2 February 2021 08:53 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/3 "2021-02-02T08:53:46Z")

</div>

Yes. I have to input a device ID into the variable, but my devices are more than 60 so each time I have to go through an excel sheet to find the ID. I was trying to write the list into a json file and present to th e dropdown list only the devices name.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [2 February 2021 09:02 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/4 "2021-02-02T09:02:29Z")

</div>

Yes, set the object to msg.options and feed that into dropdown.

---

<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: [2 February 2021 09:04 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/5 "2021-02-02T09:04:59Z")

</div>

Use a `file in` node, read the JSON data in as a string, send it through a JSON node to convert it to a JS object, then pass it through a function node to do the filtering based on device ID & format the data as required (see the built in help of the ui\_dropdown) and pass the list of options out in `msg.options` of the subflow. Connect subflow to your ui\_dropdown.

NOTE: You cannot put UI Dropdown in the subflow.

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [2 February 2021 09:08 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/6 "2021-02-02T09:08:18Z")

</div>

> [@Steve-Mcl](#):
>
> NOTE: You cannot put UI Dropdown in the subflow.

Hi Steve, in the subflow there is a way to use a dropdown:

![Schermata 2021-02-02 alle 10.07.43](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7e4f88b9ee334c297f57490c9eecdeeacc1cd62a.png)

I am not willing to use an UI dropdown, but the dropdown that is in the subflow input parameters.

---

<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: [2 February 2021 09:15 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/7 "2021-02-02T09:15:10Z")

</div>

Ah ok, no, they are statically created when you setup the subflow.

node-red editor is design time not runtime. (mostly)

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [2 February 2021 09:16 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/8 "2021-02-02T09:16:08Z")

</div>

I see... no workaround is possibile?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [2 February 2021 09:42 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/9 "2021-02-02T09:42:44Z")

</div>

No not possible. Use a msg input instead.

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [2 February 2021 09:57 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/10 "2021-02-02T09:57:32Z")

</div>

What do you mean? msg.payload as input?

- Sent from my mobile phone. Sorry for typos -

---

<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: [2 February 2021 10:07 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/11 "2021-02-02T10:07:15Z")

</div>

Hi @fmarzocca

It is not possible to dynamically generate the content in the subflow node's edit dialog - it must all be statically setup when you create the subflow template.

The only way to make that list of options dynamic would be to create a completely custom node from scratch where you can build all the custom logic in the edit dialog you would need to get the list.

There is no workaround with passing messages in _if_ you requirement is to help the user pick from a list of devices when creating their flows.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [2 February 2021 13:47 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/12 "2021-02-02T13:47:32Z")

</div>

I meant, send messages with a specific property that will be handled inside the subflow, eg;

```auto
{"stato":"up"}
...
{"stato":"stop"}

```

---

<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: [3 April 2021 13:48 UTC](https://discourse.nodered.org/t/populate-input-dropdown-from-json-file/40217/13 "2021-04-03T13:48:21Z")

</div>

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