Ui-dropdown - returns string as Infinity

Hi All,

From a MySQL I quarry the list I need in my ui-dropdown.

The fields in MySQL VARCHAR(16) and is a HEX string eg : 70B3D57050006F77 , 70A3C57050006F76, 24e1641094172783.

The change node
image

The ui-dropdown dropdown list.
image

The issue is when I select 24e1641094172783 the ui-dropdown returns Infinity, but I require the HEX to be returned as a string.

For any of the others it returns the HEX as a string, witch is correct.

image

Thank you, your input will be valued.

That does appear to be a bug, you should report it at the node-red github page.

It seems to be reading the e as number Scientific notation - Wikipedia

you could add a # to front and remove later
eg.

[{"id":"7d16429b.c68c2c","type":"inject","z":"e4f02345.29fe9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"#24E1641094172783","payloadType":"str","x":190,"y":40,"wires":[["e4be60a0.551f68"]]},{"id":"e4be60a0.551f68","type":"ui_dropdown","z":"e4f02345.29fe9","name":"","label":"","tooltip":"","place":"Select option","group":"8b5cde76.edd58","order":4,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":300,"y":120,"wires":[["33dc7075.f3c9e8"]]},{"id":"e5b387df.b88f7","type":"change","z":"e4f02345.29fe9","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"[options.$.{$:\"#\"&$}]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":200,"wires":[["e4be60a0.551f68"]]},{"id":"33dc7075.f3c9e8","type":"change","z":"e4f02345.29fe9","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"#","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":120,"wires":[["7be18ccf.fe5354"]]},{"id":"5ff0d6fe.d9b3d8","type":"inject","z":"e4f02345.29fe9","name":"","props":[{"p":"options","v":"[\"70B3D57050006F77\" , \"70A3C57050006F76\", \"24E1641094172783\"]","vt":"json"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":120,"wires":[["e5b387df.b88f7"]]},{"id":"7be18ccf.fe5354","type":"debug","z":"e4f02345.29fe9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":120,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"","disabled":false,"hidden":false}]
1 Like

I looked at your example (thank you), thought it will be simple to just split the msg and add # in front of the Hex with a quick function msg.payload.dev_id = "#" + msg.payload.dev_id; and then re-join, but at last not.

The msg form the return call from the MySQL quarry is a bit more complex.
image

SO the slit just returns [object Object] and not the ev_id
image

Will need to scratch my head a bit more on this one.

I did not see the output as number and did not catch that the number is so big and thus the Infinity.

you just need to add .dev_id after the $'s
i.e.

[{"id":"e4be60a0.551f68","type":"ui_dropdown","z":"e4f02345.29fe9","name":"","label":"","tooltip":"","place":"Select option","group":"8b5cde76.edd58","order":6,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":300,"y":120,"wires":[["33dc7075.f3c9e8"]]},{"id":"7d16429b.c68c2c","type":"inject","z":"e4f02345.29fe9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"#24E1641094172783","payloadType":"str","x":190,"y":40,"wires":[["e4be60a0.551f68"]]},{"id":"e5b387df.b88f7","type":"change","z":"e4f02345.29fe9","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"[payload.$.{$.dev_id:\"#\"&$.dev_id}]","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":200,"wires":[["e4be60a0.551f68"]]},{"id":"33dc7075.f3c9e8","type":"change","z":"e4f02345.29fe9","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"#","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":40,"wires":[["7be18ccf.fe5354"]]},{"id":"5ff0d6fe.d9b3d8","type":"inject","z":"e4f02345.29fe9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"dev_id\":\"70B3D57050006F77\"},{\"dev_id\":\"70A3C57050006F76\"},{\"dev_id\":\"24E1641094172783\"}]","payloadType":"json","x":90,"y":120,"wires":[["e5b387df.b88f7"]]},{"id":"7be18ccf.fe5354","type":"debug","z":"e4f02345.29fe9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":120,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

[edit] set for input payload

if you wanted to do it in a function try

msg.options=[];
msg.payload.forEach((v,i) => {
    msg.options[i]={};
    msg.options[i][v.dev_id]="#"+v.dev_id;
})
return msg;
1 Like

Hi - thanks - bug noted - will fix.

Thank you for your help, appreciate it.

Were thinking of adding a # when I wright the data to the db , but this is a better solution. :slight_smile: