# Ui-dropdown - returns string as Infinity

**URL:** <https://discourse.nodered.org/t/ui-dropdown-returns-string-as-infinity/40553>\
**Category:** Dashboard\
**Created:** [7 February 2021 14:30 UTC](https://discourse.nodered.org/t/ui-dropdown-returns-string-as-infinity/40553 "2021-02-07T14:30:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [7 February 2021 14:30 UTC](https://discourse.nodered.org/t/ui-dropdown-returns-string-as-infinity/40553/1 "2021-02-07T14:30:12Z")

</div>

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.

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

The change node  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/b/7bffa24ebd81b93b412c62799a80f8bdc2de3115.png)

The ui-dropdown dropdown list.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/c/bc7cf359cdf10785661554a74704b067b7c9f005.png)

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e25e59a2c226c6e009a05411f4fb3653ccedb04c.png)

Thank you, your input will be valued.

---

<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:** [7 February 2021 15:08 UTC](https://discourse.nodered.org/t/ui-dropdown-returns-string-as-infinity/40553/2 "2021-02-07T15:08:17Z")

</div>

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](https://en.m.wikipedia.org/wiki/Scientific_notation#Examples_and_other_notations)

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

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

```

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [7 February 2021 21:01 UTC](https://discourse.nodered.org/t/ui-dropdown-returns-string-as-infinity/40553/3 "2021-02-07T21:01:10Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8cac8f3fa364c1cbcfda39ffa235f119fbea324d.png)

SO the slit just returns [object Object] and not the ev\_id  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/4/042c354ebae6b6249d9ba2e753e99baf620b087a.png)

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.

---

<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:** [7 February 2021 21:17 UTC](https://discourse.nodered.org/t/ui-dropdown-returns-string-as-infinity/40553/4 "2021-02-07T21:17:01Z")

</div>

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

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

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

```

---

<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:** [7 February 2021 22:22 UTC](https://discourse.nodered.org/t/ui-dropdown-returns-string-as-infinity/40553/5 "2021-02-07T22:22:17Z")

</div>

Hi - thanks - bug noted - will fix.

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [8 February 2021 06:04 UTC](https://discourse.nodered.org/t/ui-dropdown-returns-string-as-infinity/40553/6 "2021-02-08T06:04:07Z")

</div>

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. 🙂

---

<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:** [10 March 2021 06:04 UTC](https://discourse.nodered.org/t/ui-dropdown-returns-string-as-infinity/40553/7 "2021-03-10T06:04:40Z")

</div>

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