I'm getting "TypeError: Cannot read property '0' of undefined" once I used the switch node. I'm not sure where it went wrong.
Thanks for helping.
[{"id":"b107d7d0.8bcf98","type":"function","z":"87eeee6.729851","name":"select-query","func":"//var name = {payload: (msg.payload.name)};\n//msg.payload = name;\nvar select = {topic: \"SELECT COUNT(*) AS count FROM test WHERE name='\" + msg.payload.name + \"'\"};\n\nreturn select;","outputs":1,"noerr":0,"x":670,"y":120,"wires":[["ce323c92.b8766","ea75af48.2081b"]]},{"id":"cb5c2136.c89d5","type":"function","z":"87eeee6.729851","name":"insert-query","func":"//var cntStr = {payload: (msg.payload[0])};\n//var count = {payload: (cntStr.payload.count)};\n\n//if (msg.payload[0].count === 0)\n//{\n\tinsert = {topic: \"INSERT INTO test (name,lastname,code) VALUES ('\"+ msg.payload.name +\"','\"+ msg.payload.lastname +\"','\"+ msg.payload.code +\"')\"};\n\tactionString = \"Data inserted successfully!\";\n\treturn [insert,actionString];\n/*}\nelse\n{\n\tactionString = \"Data insertion failed!\";\n\tmsg.payload = actionString;\n return msg;\n}*/","outputs":1,"noerr":0,"x":1070,"y":180,"wires":[["a91e26c5.d2ed48","c86b585b.736d78"]]},{"id":"a91e26c5.d2ed48","type":"debug","z":"87eeee6.729851","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1290,"y":120,"wires":[]},{"id":"bd18f1d0.01967","type":"switch","z":"87eeee6.729851","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"save-button","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":470,"y":120,"wires":[["b107d7d0.8bcf98"]]},{"id":"7e1ee6ef.c4ec08","type":"mui_button","z":"87eeee6.729851","name":"save-button","group":"862f3f87.367da","order":4,"width":0,"height":0,"passthru":false,"label":"Save","color":"","bgcolor":"","icon":"","payload":"{}","payloadType":"global","topic":"save-button","x":90,"y":220,"wires":[["4f6f5725.bf21d8"]]},{"id":"8f59d5e9.f9bf98","type":"mui_text_input","z":"87eeee6.729851","name":"name","label":"Name","group":"862f3f87.367da","order":1,"width":0,"height":0,"passthru":false,"mode":"text","delay":300,"topic":"name","x":70,"y":40,"wires":[["4f6f5725.bf21d8"]]},{"id":"17abf0bb.ba670f","type":"mui_dropdown","z":"87eeee6.729851","name":"lastname","label":"","place":"Select Last Name","group":"862f3f87.367da","order":2,"width":0,"height":0,"passthru":false,"options":[{"label":"Rishan","value":1,"type":"num"},{"label":"Login","value":2,"type":"num"}],"payload":"","topic":"lastname","x":80,"y":100,"wires":[["4f6f5725.bf21d8"]]},{"id":"a8d9a9b0.81f358","type":"mui_text_input","z":"87eeee6.729851","name":"code","label":"Code","group":"862f3f87.367da","order":3,"width":0,"height":0,"passthru":false,"mode":"text","delay":300,"topic":"code","x":70,"y":160,"wires":[["4f6f5725.bf21d8"]]},{"id":"4f6f5725.bf21d8","type":"join","z":"87eeee6.729851","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":290,"y":120,"wires":[["bd18f1d0.01967"]]},{"id":"ce323c92.b8766","type":"mysql","z":"87eeee6.729851","mydb":"272ea16.4569d5e","name":"database","x":880,"y":120,"wires":[["a91e26c5.d2ed48"]]},{"id":"ea75af48.2081b","type":"switch","z":"87eeee6.729851","name":"","property":"payload[0].count","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":240,"wires":[["cb5c2136.c89d5"],["617d5616.2edfb8"]]},{"id":"617d5616.2edfb8","type":"function","z":"87eeee6.729851","name":"failure-msg","func":"actionString = \"Data insertion failed!\";\nmsg.payload = actionString;\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":300,"wires":[["a91e26c5.d2ed48"]]},{"id":"c86b585b.736d78","type":"mysql","z":"87eeee6.729851","mydb":"272ea16.4569d5e","name":"database","x":1280,"y":180,"wires":[[]]},{"id":"862f3f87.367da","type":"mui_group","z":"","name":"Input Test - Multiple Users","tab":"29df8a3d.2c7ba6","order":1,"disp":true,"width":"6","collapse":false},{"id":"272ea16.4569d5e","type":"MySQLdatabase","z":"","host":"192.168.3.10","port":"3306","db":"ram_test","tz":""},{"id":"29df8a3d.2c7ba6","type":"mui_tab","z":"","name":"I4Inari","icon":"dashboard","order":1}]