UI Dropdown Single Entry selection problem

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.

[{"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

Image of the flow for reference

Code of function Node Get TagValues values
image

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

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

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

[{"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}]

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

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