Dropdown node cuts a "0" at the end

Hi, I'm new to node red and maybe someone can help me with my dropdown node.
I have a query to a mysql database where I select article numbers.
The delivered data is an array.
The article numbers look e.g. like 44700.31; 45600.63; 44602.20
But when I go into the dropdown node every number with a "0" at the end changes.
Should be "44602.20" but is "44602.2". This only happens with the "0" at the end.
I tried a lot but have not been successful up to now.

Thanks for your help!


In javascript, a value of type 'number' will trim the trailing zeros to the right of the decimal. You might have to keep the value as a type 'string' so that it stays.

You can change the numbers to string with two decimal places using toFixed(). JavaScript toFixed() Method

Thank you for your answers! I decided to change the input to a string.
This is the contens ofmy function node going to the dropdown field:

//as per info panel, the data needs to be formatted
//as [ "Choice 1", "Choice 2", {"Choice 3":"3"} ]
//and sent in msg.options.
msg.options = [];//create empty array
for(let i = 0; i < msg.payload.length; i++){
    let row = msg.payload[i]; //get the row
    let opt = {};//make new opt object
    opt[row.Materialnummer] = row.Materialnummer; 
    msg.options.push(opt);//add the opt to array    
return msg;

I tried to change the "row" to row_string = row.toString()
but it doesn't work.
Does anyone have an idea?

thanks in advance

In what way doesn't it work?

What do you see if you feed the function into a debug node set to show Complete Message.

Hi Colin,
when i add in the above function node
" row = (row.ToString()); "
and i add an debug node after the function node I can not see any difference. But the following dropdown node can't select no more one option. The output is the complete array, while without this .ToString() there is only one mateialnumber selected.
Thanks for your help

Show us what you see in the debug node. You said you can't see any difference, but if it changes what happens then there must be a difference.
Also show us what you have in the function now.

flows.json (554 Bytes)
Hi Colin,
i attached a simple example of my flow.
When you select any article number the "0" at the end is cut.
Do have any idea how to solve that? I tried a lot but had no success.
Thanks for your help


For the future please see this post for how to post flows - How to share code or flow json

Unfortunately you have only posted the dropdown node, not the function node, and you have not done what I asked which was

[{"id":"9bd7e49e.1dbab8","type":"function","z":"8db0322a.4cc4d","name":"transform data to correct format","func":"//as per info panel, the data needs to be formatted\n//as [ \"Choice 1\", \"Choice 2\", {\"Choice 3\":\"3\"} ]\n//and sent in msg.options.\nmsg.options = [];//create empty array\nfor(let i = 0; i < msg.payload.length; i++){\n    let row = msg.payload[i]; //get the row\n    let opt = {};//make new opt object\n    opt[row[0]] = row[1]; //add a propery to object called row[0] & set its value to row[1]\n    msg.options.push(opt);//add the opt to array    \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":240,"wires":[["f2042e3d.90c87"]]}]

Hi Colin,
thank you for your patience :slight_smile:

I think three times I have asked you to post what you see if you connect the latest version of the function node to a debug node, so we can see what it currently sends.

this is the output from the function node:

and this is the output from the dropdown node:

maybe also the output of the debug node after the function node in an other way:


It appears there is a bug. I am able to replicate the problem with this flow


The dropdown node returns a number instead of a string. I have a vague recollection of this being fixed ages ago, perhaps somehow it has returned.
That is with node-red 1.3.4 and dashboard 2.29.0
If I hard code the options into the dropdown node then it is fine.

@knolleary should I submit an issue for this?

[{"id":"f2042e3d.90c87","type":"ui_dropdown","z":"84405ff5.25fa6","name":"","label":"","tooltip":"","place":"Select option","group":"807b5c7.909b2a","order":12,"width":0,"height":0,"passthru":true,"multiple":false,"options":[],"payload":"","topic":"topic","topicType":"msg","x":280,"y":1140,"wires":[["92dcc263.ad2058"]]},{"id":"b25f37ba.1a80c","type":"inject","z":"84405ff5.25fa6","name":"options: [{\"33640.20\":\"33640.20\"},{\"35789.30\":\"35789.30\"}]","props":[{"p":"options","v":"[{\"33640.20\":\"33640.20\"},{\"35789.30\":\"35789.30\"}]","vt":"json"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"str","x":280,"y":1080,"wires":[["f2042e3d.90c87"]]},{"id":"92dcc263.ad2058","type":"debug","z":"84405ff5.25fa6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":430,"y":1140,"wires":[]},{"id":"807b5c7.909b2a","type":"ui_group","name":"Group 1","tab":"4b4528d.4e9cad8","order":1,"disp":true,"width":6},{"id":"4b4528d.4e9cad8","type":"ui_tab","name":"Example","icon":"dashboard","order":8,"disabled":false,"hidden":false}]

I think perhaps I should have tagged @dceejay on this question as it is a dashboard issue.

yes please raise issue with your example flow. thanks

Issue raised Dropdown node sending numbers instead of strings · Issue #700 · node-red/node-red-dashboard · GitHub

@tim26 if you know the values are always of that format, then as a temporary workaround you could add after the dropdown node a Function node containing

msg.payload = msg.payload.toFixed(2)
return msg

Dear all,
thank you for your support!
Unfortunately the article numbers do not all follow this pattern.
I think i have to add a condition what the article number looks like.

For the numbers which follow this pattern your solution works fine.

Thanks a lot


Pushed fix as 2.29.1