Hello. I am trying to figure out the most logical way to build a 3 element payload array and out of form and dropdown nodes.
1 variable comes from "dropdown" node ( "Device")
2 variables comes from "form" node ("Item", "Serial").
I have initially built this flow:
However, with this flow I am facing a problem - whenever I select an item from dropdown menu, it immidiately sends an output signal to "join" node which is configured to count to 3. Another 2 variables come from "form" node. If an operator makes a mistake or needs to change the device from dropdown menu, it will automatically trigger another output signal and add +1 to the counter in join node which will only leave me 1 variable available which is not correct!
What I want to build instead, is a simmilar approach but instead, I would fill my array DBdata[2] with the variables from form and dropdown, and only send the data to the output when I press a button. I have tried to implement it here:
flow:
[{"id":"9d8656d9.cb81f8","type":"debug","z":"beb7a2a.0c08b6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":1900,"wires":[]},{"id":"7e41d220.32d40c","type":"mui_form","z":"beb7a2a.0c08b6","name":"","label":"Add data to MYSQL pack_to_light table test","group":"f9b77890.739788","order":2,"width":0,"height":0,"options":[{"label":"Item","value":"Item","type":"text","required":true,"rows":null},{"label":"Serial","value":"Serial","type":"number","required":true,"rows":null}],"formValue":{"Item":"","Serial":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":310,"y":1760,"wires":[["e351811f.0731","4ea178f0.80ad28"]]},{"id":"e5601425.fee918","type":"mui_dropdown","z":"beb7a2a.0c08b6","name":"","label":"Select device test","tooltip":"","place":"Select option","group":"f9b77890.739788","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"Device1","value":"Device1","type":"str"},{"label":"Device2","value":"Device2","type":"str"},{"label":"Device3","value":"Device3","type":"str"}],"payload":"","topic":"","x":250,"y":1680,"wires":[["b633b442.b45bc8"]]},{"id":"b633b442.b45bc8","type":"change","z":"beb7a2a.0c08b6","name":"set flow DBdata","rules":[{"t":"set","p":"DBdata[0]","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1680,"wires":[["9750fe28.a955d"]]},{"id":"e351811f.0731","type":"change","z":"beb7a2a.0c08b6","name":"set flow DBdata","rules":[{"t":"set","p":"DBdata[1]","pt":"flow","to":"payload.Item","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1740,"wires":[["24f20766.7504e8"]]},{"id":"4ea178f0.80ad28","type":"change","z":"beb7a2a.0c08b6","name":"set flow DBdata","rules":[{"t":"set","p":"DBdata[2]","pt":"flow","to":"payload.Serial","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1780,"wires":[["a782eb90.9ff0b8"]]},{"id":"e586ad95.c891e","type":"mui_button","z":"beb7a2a.0c08b6","name":"","group":"f9b77890.739788","order":4,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":230,"y":1900,"wires":[["2ff66de1.36f8e2"]]},{"id":"a782eb90.9ff0b8","type":"debug","z":"beb7a2a.0c08b6","name":"SErial","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":1780,"wires":[]},{"id":"24f20766.7504e8","type":"debug","z":"beb7a2a.0c08b6","name":"Item","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":1740,"wires":[]},{"id":"9750fe28.a955d","type":"debug","z":"beb7a2a.0c08b6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":1680,"wires":[]},{"id":"2ff66de1.36f8e2","type":"change","z":"beb7a2a.0c08b6","name":"Add 3 flows to build an array","rules":[{"t":"set","p":"payload[0]","pt":"flow","to":"DBdata[0]","tot":"flow"},{"t":"set","p":"payload[1]","pt":"flow","to":"DBdata[1]","tot":"flow"},{"t":"set","p":"payload[2]","pt":"flow","to":"DBdata[2]","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":1900,"wires":[["9512d53c.d579c8"]]},{"id":"9512d53c.d579c8","type":"debug","z":"beb7a2a.0c08b6","name":"combined","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":640,"y":1980,"wires":[]},{"id":"f9b77890.739788","type":"mui_group","name":"mGroup 1","tab":"5d85eb08.22c5a4","order":1,"disp":true,"width":6},{"id":"5d85eb08.22c5a4","type":"mui_tab","name":"Tab 2","icon":"dashboard","order":2}]
However, it does not seem to work as I have expected - it does not add the payloads when the button is pressed.
Switch node for each variable looks like this:
Switch node when button is pressed:
Join node:
Any ideas on how to make it work properly?