# UI Dropdown Single Entry selection problem

**URL:** <https://discourse.nodered.org/t/ui-dropdown-single-entry-selection-problem/47743>\
**Category:** Dashboard\
**Created:** [28 June 2021 11:17 UTC](https://discourse.nodered.org/t/ui-dropdown-single-entry-selection-problem/47743 "2021-06-28T11:17:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lizhong](https://avatars.discourse-cdn.com/v4/letter/l/c4cdca/32.png) [@lizhong](https://discourse.nodered.org/u/lizhong)\
**Post date:** [28 June 2021 11:17 UTC](https://discourse.nodered.org/t/ui-dropdown-single-entry-selection-problem/47743/1 "2021-06-28T11:17:24Z")

</div>

Hi all, I am currently attempting to populate my dropdown UI dynamically based on the results from my queries from my InfluxDB. Then selecting the options, I set the options to my flow context where I wish to work with further.

Populating my Dropdown UI was successful and selecting them when there are multiple options worked. However, the problem arise when there is only a single option available to me. Selecting the single option doesn't seem to show up. This can be confirmed when I select and my flow variable doesn't show up.

```auto
[{"id":"7d06c5e1.55ce1c","type":"function","z":"c8ba669.7292398","name":"Get TagValues values","func":"var arr = [];\nvar i;\n\nfor(i=0; i< msg.payload.length; i++){\n arr[i] = msg.payload[i]._value;\n}\n\nmsg.payload = arr;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":1760,"wires":[["3f81a46a.9a233c"]]},{"id":"3f81a46a.9a233c","type":"change","z":"c8ba669.7292398","name":"Set ID values to Options","rules":[{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":1760,"wires":[["cfc73d1a.b1347"]]},{"id":"cfc73d1a.b1347","type":"ui_dropdown","z":"c8ba669.7292398","name":"","label":"TagValues","tooltip":"Show available TagValues from selected Measurement & TagKeys","place":"Select option","group":"382edf47.d12b3","order":9,"width":6,"height":3,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","topicType":"str","x":830,"y":1760,"wires":[["3fbf31a0.b3e2be","a64b20c1.97316"]]},{"id":"3fbf31a0.b3e2be","type":"change","z":"c8ba669.7292398","name":"","rules":[{"t":"set","p":"tagvalues","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":1760,"wires":[[]]},{"id":"382edf47.d12b3","type":"ui_group","name":"InfluxDB Query & Delete","tab":"7bbd3bc8.7e32d4","order":2,"disp":true,"width":22,"collapse":false},{"id":"7bbd3bc8.7e32d4","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

What you see is a node that accepts my query results in array form and add them one by one into my payload before converting them to msg.options for the dropdown node. Output of dropdown node will then be selected to be set into flow context.

Thanks

---

<div class="post-metadata">

**Author:** ![lizhong](https://avatars.discourse-cdn.com/v4/letter/l/c4cdca/32.png) [@lizhong](https://discourse.nodered.org/u/lizhong)\
**Post date:** [28 June 2021 11:25 UTC](https://discourse.nodered.org/t/ui-dropdown-single-entry-selection-problem/47743/2 "2021-06-28T11:25:24Z")

</div>

Image of the flow for reference

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/28fe5355f04890a8174d1e487627e1592c3b46d6.png)

Code of function Node Get TagValues values  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/4686d3148dae6961067bdf00283a356aae8adf71.png)

---

<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:** [28 June 2021 12:00 UTC](https://discourse.nodered.org/t/ui-dropdown-single-entry-selection-problem/47743/3 "2021-06-28T12:00:05Z")

</div>

Once a value has been selected once, unless that value changes the dropdown will not pass it on again.

---

<div class="post-metadata">

**Author:** ![lizhong](https://avatars.discourse-cdn.com/v4/letter/l/c4cdca/32.png) [@lizhong](https://discourse.nodered.org/u/lizhong)\
**Post date:** [28 June 2021 12:07 UTC](https://discourse.nodered.org/t/ui-dropdown-single-entry-selection-problem/47743/4 "2021-06-28T12:07:00Z")

</div>

I see. Could there be a possible way to bypass this?  
Because I sometime do get only single result on my queries.

---

<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:** [28 June 2021 12:17 UTC](https://discourse.nodered.org/t/ui-dropdown-single-entry-selection-problem/47743/5 "2021-06-28T12:17:37Z")

</div>

You could add a second final option. Then if you filter this option out, it will allow you to reselect first option  
e.g.

```auto
[{"id":"cae97007.6a9478","type":"inject","z":"a80913f6.edcdb8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"_value\":1}]","payloadType":"json","x":420,"y":380,"wires":[["6cd9930f.25828c"]]},{"id":"6cd9930f.25828c","type":"function","z":"a80913f6.edcdb8","name":"Get TagValues values","func":"var arr = [];\nvar i;\n\nfor(i=0; i< msg.payload.length; i++){\n arr[i] = msg.payload[i]._value;\n}\narr.push(\"reset\");\nmsg.payload = arr;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":320,"wires":[["f714b58c.dad408"]]},{"id":"f714b58c.dad408","type":"change","z":"a80913f6.edcdb8","name":"Set ID values to Options","rules":[{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":320,"wires":[["2117cf83.dec01"]]},{"id":"2117cf83.dec01","type":"ui_dropdown","z":"a80913f6.edcdb8","name":"","label":"TagValues","tooltip":"Show available TagValues from selected Measurement & TagKeys","place":"Select option","group":"5fd0cd91.d30204","order":9,"width":6,"height":3,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","topicType":"str","x":990,"y":320,"wires":[["d8848b55.6f9e68"]]},{"id":"d8848b55.6f9e68","type":"switch","z":"a80913f6.edcdb8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"reset","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1140,"y":320,"wires":[["2b7ef29c.474556"]]},{"id":"2b7ef29c.474556","type":"debug","z":"a80913f6.edcdb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1350,"y":320,"wires":[]},{"id":"5fd0cd91.d30204","type":"ui_group","name":"InfluxDB Query & Delete","tab":"7bbd3bc8.7e32d4","order":2,"disp":true,"width":22,"collapse":false},{"id":"7bbd3bc8.7e32d4","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![lizhong](https://avatars.discourse-cdn.com/v4/letter/l/c4cdca/32.png) [@lizhong](https://discourse.nodered.org/u/lizhong)\
**Post date:** [28 June 2021 12:39 UTC](https://discourse.nodered.org/t/ui-dropdown-single-entry-selection-problem/47743/6 "2021-06-28T12:39:49Z")

</div>

I've done what you have recommended and it worked. Thanks a lot!

---

<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:** [12 July 2021 12:40 UTC](https://discourse.nodered.org/t/ui-dropdown-single-entry-selection-problem/47743/7 "2021-07-12T12:40:01Z")

</div>

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