Fill dropdown by function node

Hello experts!

I'm trying to fill a dropdown but cant get it work! Whats wrong with my code?

var msg2 = {};

msg2.options = [];

for (let i=0; i<msg.payload.length; i++)
    var label = msg.payload[i].Timestamp__OrderStart.toLocaleString()+"; Anzahl: "+msg.payload[i].PartsCount.toString();
    var value = i;
    var s = {label:value};

return msg2;

try var s = {[label]: value};
Javascript interprets label as a string key not a var, the square bracket tells it to treat it a a variable.

1 Like

Thats it! Thanks!

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