hi everyone i wish that you are fine,
as @Colin and @Steve-Mcl and others helped me I'm thankful for you ...
i have worked on a project it's about tracking events in a machine we want to not turn on this machine just if the operator entre the code and his name in a form node it's a Mitsubishi PLC so i have this flow but i have a problem with data type and issues with object array and if you can help me to clean my flow please i just want send data to CSV file with the current DateTime and send a TRUE to the PLC when the operator enter data in form if the operator didn't write anything the msg will send nothing to PLC using th MC Write NODE
[{"id":"4a6ba2c4.481ffc","type":"tab","label":"Flow 8","disabled":false,"info":""},{"id":"317e7cb2.f1c6a4","type":"function","z":"4a6ba2c4.481ffc","name":"Store Data","func":"var data1 = context.get(\"data1\") || 0; //get from context or default to 0\nvar data2 = context.get(\"data2\") || 0; //get from context or default to 0\n\nswitch (msg.topic){\n\n case \"task1\":\n data1 = msg.payload; \n context.set(\"data1\", data1);//store in context for next time \n return;\n \n case \"task2\":\n data2 = msg.payload;\n context.set(\"data2\", data2); //store in context for next time \n return;\n \n case \"Marche\":\n \n {\n if( data1 == '0' && data2 == '0')\n \n { msg.payload = undefined}\n \n else \n {msg.payload = \" text 1 \"+ data1 +\" , text2 \" + data2;}\n \n }\n}\n\n//msg.topic = \"go\";\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":120,"wires":[["61dcc596.e55b5c","cdefef64.81613"]]},{"id":"b74b6e1.b73569","type":"ui_text_input","z":"4a6ba2c4.481ffc","name":"","label":"code","tooltip":"","group":"a63b29d.f4c81d8","order":2,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"task1","topicType":"str","x":70,"y":80,"wires":[["317e7cb2.f1c6a4"]]},{"id":"9439235c.d3aef","type":"ui_text_input","z":"4a6ba2c4.481ffc","name":"","label":"Operateur","tooltip":"","group":"a63b29d.f4c81d8","order":3,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"task2","topicType":"str","x":80,"y":120,"wires":[["317e7cb2.f1c6a4"]]},{"id":"d29cd09b.cf787","type":"ui_button","z":"4a6ba2c4.481ffc","name":"","group":"a63b29d.f4c81d8","order":4,"width":0,"height":0,"passthru":false,"label":"Marche","tooltip":"","color":"","bgcolor":"green","icon":"","payload":"","payloadType":"str","topic":"Marche","topicType":"str","x":90,"y":160,"wires":[["317e7cb2.f1c6a4"]]},{"id":"7863dc7e.13b5d4","type":"debug","z":"4a6ba2c4.481ffc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":60,"wires":[]},{"id":"61dcc596.e55b5c","type":"json","z":"4a6ba2c4.481ffc","name":"","property":"payload","action":"str","pretty":true,"x":470,"y":120,"wires":[["36fd165f.4d09ca"]]},{"id":"36fd165f.4d09ca","type":"file","z":"4a6ba2c4.481ffc","name":"","filename":"C:\\Users\\pc\\Desktop\\test.csv","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":680,"y":120,"wires":[["7863dc7e.13b5d4"]]},{"id":"cdefef64.81613","type":"function","z":"4a6ba2c4.481ffc","name":"Store Data","func":"if (msg.payload == undefined)\n\n{\t\n msg.payload = \"Entre the reason\";\t\n\n}\nelse\n{\n msg.payload = true;\n\n\n}\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":200,"wires":[["7bae3da0.ffb114","4f0b37f3.4670d8","e8777ad0.04c158"]]},{"id":"7bae3da0.ffb114","type":"debug","z":"4a6ba2c4.481ffc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":200,"wires":[]},{"id":"4f0b37f3.4670d8","type":"ui_toast","z":"4a6ba2c4.481ffc","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":true,"topic":"","name":"","x":500,"y":320,"wires":[]},{"id":"e4f3e3a0.c8f38","type":"MC Write","z":"4a6ba2c4.481ffc","name":"marche","topic":"","connection":"8a67d1bd.c84ff","data":"payload","address":"D0","addressType":"str","dataType":"msg","errorHandling":"throw","outputs":1,"x":740,"y":260,"wires":[["6f06958a.8d219c"]]},{"id":"6f06958a.8d219c","type":"debug","z":"4a6ba2c4.481ffc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":440,"wires":[]},{"id":"e8777ad0.04c158","type":"function","z":"4a6ba2c4.481ffc","name":"Store Data","func":"if (msg.payload == undefined)\n\n{\t\n msg.payload = \"Entre the reason\";\t\n\n}\nelse\n{\n msg.payload = true;\n\n\n}\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":260,"wires":[["e4f3e3a0.c8f38"]]},{"id":"a63b29d.f4c81d8","type":"ui_group","name":"Form","tab":"4bed3390.45d6dc","order":1,"disp":true,"width":"15","collapse":false},{"id":"8a67d1bd.c84ff","type":"MC Protocol Connection","name":"","host":"localhost","port":"5003","protocol":"UDP","frame":"4E","plcType":"Q","ascii":false,"PLCStation":"","PCStation":"","PLCModuleNo":"","network":"","octalInputOutput":false,"timeout":"3000"},{"id":"4bed3390.45d6dc","type":"ui_tab","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]```