Ok, i spotted your issue - you discard the incomming msg
in function "My SQL Database Request" and instead send a new msg2
object.
As i said earlier...
... you are effectively removing the necessary parts of the msg
for it to respond to the caller.
try this...
[{"id":"53cb80.1fbbb48","type":"ui_date_picker","z":"30e2e9e0.eeaab6","name":"","label":"Start Date","group":"f26fc68d.b2996","order":1,"width":"5","height":"5","passthru":true,"topic":"start_date","x":180,"y":920,"wires":[["5b8389e0.371f88"]]},{"id":"1d1317a5.ebe9c8","type":"ui_date_picker","z":"30e2e9e0.eeaab6","name":"","label":"End Date","group":"f26fc68d.b2996","order":2,"width":"5","height":"5","passthru":true,"topic":"end_date","x":180,"y":960,"wires":[["5492cbec.551d34"]]},{"id":"7bb17c6a.e09a04","type":"function","z":"30e2e9e0.eeaab6","name":"My SQL Database Request","func":"var port= \"dewa_10\"; //replace with port no\nvar startDate = flow.get(\"startDate\");\nvar endDate = flow.get(\"endDate\");\nmsg.topic=\"select * from (select substr(datetime, 1, 13) as waktu, `pi`,`ti`,status,mode,engine_volt,motor_frequency,`motor_voltage`,`motor_current`,`dts` from \"+port+\" WHERE datetime BETWEEN '\"+startDate+\"' AND '\"+endDate+\"' order by datetime ) t GROUP BY waktu\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":1120,"wires":[["cd8e581.20defa8"]]},{"id":"cd8e581.20defa8","type":"mysql","z":"30e2e9e0.eeaab6","mydb":"ebf52c2e.a8b058","name":"","x":470,"y":1120,"wires":[["d8d04990.bd0d28","ac42262f.104ef"]]},{"id":"d8d04990.bd0d28","type":"csv","z":"30e2e9e0.eeaab6","name":"","sep":",","hdrin":"","hdrout":"all","multi":"mult","ret":"\\r\\n","temp":"waktu,pi,ti,status,mode,engine,mf,mv,mc,dts","skip":"0","strings":false,"include_empty_strings":false,"include_null_values":false,"x":650,"y":1120,"wires":[["216a4830.f7526","c768a229.381808"]]},{"id":"6815af8f.c938c8","type":"http response","z":"30e2e9e0.eeaab6","name":"","statusCode":"","headers":{},"x":970,"y":1120,"wires":[]},{"id":"d5cbfb5a.4fe68","type":"catch","z":"30e2e9e0.eeaab6","name":"","scope":null,"uncaught":false,"x":200,"y":1180,"wires":[["9808c14b.60f0f","56c02bc6.f48c54"]]},{"id":"9808c14b.60f0f","type":"function","z":"30e2e9e0.eeaab6","name":"Set 404","func":"msg.payload = msg.error;\nmsg.statusCode = 404;//resource not found\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":800,"y":1180,"wires":[["6815af8f.c938c8"]]},{"id":"56c02bc6.f48c54","type":"debug","z":"30e2e9e0.eeaab6","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":230,"y":1240,"wires":[]},{"id":"cf1dc7e6.d577e8","type":"ui_template","z":"30e2e9e0.eeaab6","group":"f26fc68d.b2996","name":"ui_temlplate - present download link on dashboard","order":0,"width":0,"height":0,"format":"<div >\n <a href=\"/data\">CLICK TO DOWNLOAD</a>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":570,"y":1240,"wires":[[]]},{"id":"5721ab4c.15e954","type":"http in","z":"30e2e9e0.eeaab6","name":"","url":"/data","method":"get","upload":false,"swaggerDoc":"","x":180,"y":1060,"wires":[["7bb17c6a.e09a04"]]},{"id":"216a4830.f7526","type":"function","z":"30e2e9e0.eeaab6","name":"Set Headers","func":"msg.headers = {}\nmsg.headers[\"Content-type\"] = \"text/csv\";\nmsg.headers[\"Content-Disposition\"] = \"attachment; filename=data.csv\";\nmsg.headers[\"Pragma\"] = \"no-cache\";\nmsg.headers[\"Expires\"] = \"0\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":810,"y":1120,"wires":[["6815af8f.c938c8"]]},{"id":"3668080d.9e73e8","type":"change","z":"30e2e9e0.eeaab6","name":"","rules":[{"t":"set","p":"startDate","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":920,"wires":[[]]},{"id":"7c014c58.e8d504","type":"change","z":"30e2e9e0.eeaab6","name":"","rules":[{"t":"set","p":"endDate","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":960,"wires":[[]]},{"id":"ac42262f.104ef","type":"debug","z":"30e2e9e0.eeaab6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":470,"y":1060,"wires":[]},{"id":"c768a229.381808","type":"debug","z":"30e2e9e0.eeaab6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":1060,"wires":[]},{"id":"5492cbec.551d34","type":"moment","z":"30e2e9e0.eeaab6","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Asia/Bangkok","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD","locale":"en_GB","output":"payload","outputType":"msg","outTz":"Asia/Bangkok","x":370,"y":960,"wires":[["7c014c58.e8d504"]]},{"id":"5b8389e0.371f88","type":"moment","z":"30e2e9e0.eeaab6","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Asia/Bangkok","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD","locale":"en_GB","output":"payload","outputType":"msg","outTz":"Asia/Bangkok","x":370,"y":920,"wires":[["3668080d.9e73e8"]]},{"id":"f26fc68d.b2996","type":"ui_group","name":"DEWA-10 Chart-Logger","tab":"48814208.274a2c","order":1,"disp":false,"width":"50","collapse":false},{"id":"ebf52c2e.a8b058","type":"MySQLdatabase","name":"","host":"127.0.0.1","port":"3306","db":"field_adera","tz":""},{"id":"48814208.274a2c","type":"ui_tab","name":"DEWA-10 Chart-Logger","icon":"dashboard","order":397,"disabled":false,"hidden":true}]