Hi..
I am using ui_dropdown node. I am able to set msg.options in change node and populated in dropdown for single entry but when I try to inject multiple entries, it is repopulating or refreshing the menu. How to populate in dropdown menu in dashboard. In the flow, there are different msg.topic's, I need to split and should remove duplicates if any. I have only problem with msg.options to dropdown, if multiple entries given continuously.
For that not to loose values in arrays, I have created global arrays. which inject once and whenever function node executes, those values will be stored.
here is the flow..
[{"id":"ae72b941.c54948","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"cfcfc88f.6c3888","type":"inject","z":"ae72b941.c54948","name":"Initialization","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.5","topic":"","payload":"","payloadType":"date","x":130,"y":380,"wires":[["bc6d90a5.5df89"]]},{"id":"bc6d90a5.5df89","type":"function","z":"ae72b941.c54948","name":"","func":"const domainSet = []; //msg.topic[0]\nconst nodeSet = []; //msg.topic[1];\n\nglobal.set(\"domain_Arr\", domainSet);\nglobal.set(\"node_Arr\", nodeSet);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":380,"wires":[[]]},{"id":"8f95d1f8.dfca8","type":"inject","z":"ae72b941.c54948","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"test1/Node1/2/Data","payload":"{\"ID\":\"13dfsl48\",\"TimeStamp\":0,\"SensorNamwe\":\"Sensor_3\",\"SensorRaw\":-332,\"SensorCal\":-234}","payloadType":"json","x":130,"y":480,"wires":[["8e7e2f4d.29d91"]]},{"id":"a7b7c128.f77b9","type":"inject","z":"ae72b941.c54948","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"4","crontab":"","once":false,"onceDelay":0.1,"topic":"test2/Node2/3/Data","payload":"{\"ID\":\"2e3fffs\",\"TimeStamp\":0,\"SensorNamwe\":\"Sensor_5\",\"SensorRaw\":-197,\"SensorCal\":-165}","payloadType":"json","x":130,"y":540,"wires":[["8e7e2f4d.29d91"]]},{"id":"8e7e2f4d.29d91","type":"json","z":"ae72b941.c54948","name":"","property":"payload","action":"obj","pretty":true,"x":290,"y":520,"wires":[["e3552595.566938","de237166.3276b"]]},{"id":"e3552595.566938","type":"function","z":"ae72b941.c54948","name":"","func":"\nvar NodeArray = global.get(\"node_Arr\");\n\nvar Topic = msg.topic.split(\"/\");\nvar Node = Topic[1];\nNodeArray.push(Node);\n\n//Removing duplicates in Array\nlet y = (NodeArray) => NodeArray.filter((v,i) => NodeArray.indexOf(v) === i)\nconst unQNodeArr = y(NodeArray);\n\n\nmsg.options = unQNodeArr;\n// return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":540,"wires":[["d5568bfb.00b7c8"]]},{"id":"de237166.3276b","type":"function","z":"ae72b941.c54948","name":"","func":"\nvar DomainArray = global.get(\"domain_Arr\");\nlet Topic = msg.topic.split(\"/\");\n\nvar Domain = Topic[0];\nDomainArray.push(Domain);\n\n//Removing duplicates in Array\nlet x = (DomainArray) => DomainArray.filter((v,i) => DomainArray.indexOf(v) === i)\nconst unQDomainArr = x(DomainArray);\n\nmsg.options = unQDomainArr;\n// return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":500,"wires":[["f61ee996.db28e8"]]},{"id":"f61ee996.db28e8","type":"change","z":"ae72b941.c54948","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":500,"wires":[["af33f919.47e1c8"]]},{"id":"d5568bfb.00b7c8","type":"change","z":"ae72b941.c54948","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":540,"wires":[["996903c6.7f2f7"]]},{"id":"af33f919.47e1c8","type":"ui_dropdown","z":"ae72b941.c54948","name":"","label":"Select the Domain","tooltip":"","place":"Select option","group":"f4ddc713.cb9a58","order":2,"width":"6","height":1,"passthru":true,"multiple":false,"options":[],"payload":"","topic":"","x":830,"y":500,"wires":[[]]},{"id":"996903c6.7f2f7","type":"ui_dropdown","z":"ae72b941.c54948","name":"","label":"Select the Node","tooltip":"","place":"Select option","group":"f4ddc713.cb9a58","order":1,"width":"6","height":1,"passthru":true,"multiple":false,"options":[],"payload":"","topic":"","x":820,"y":540,"wires":[[]]},{"id":"c729fc1e.8194c","type":"inject","z":"ae72b941.c54948","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":false,"onceDelay":0.1,"topic":"test3/Node3/4/Data","payload":"{\"ID\":\"3fg4rks\",\"TimeStamp\":0,\"SensorNamwe\":\"Sensor_5\",\"SensorRaw\":-197,\"SensorCal\":-165}","payloadType":"json","x":130,"y":600,"wires":[["8e7e2f4d.29d91"]]},{"id":"f4ddc713.cb9a58","type":"ui_group","name":"T1","tab":"763667c5.ae1af8","order":1,"disp":true,"width":"6","collapse":false},{"id":"763667c5.ae1af8","type":"ui_tab","name":"LAB","icon":"dashboard"}]```