Downloading csv file generated by MySQL database after pressing a form button

maybe because your 'simulated' data doesnt match the 'real' context.

send us a screenshot of the context data from your real flow .. expanded so we can see the whole structure pls

as

i think i found the issue .. you need an extra space infront of VALUES in sql query .. try this
because your sql resolves to

"INSERT INTO Andadores (ID_and,ID_pac,Inicio)VALUES (54,26,2020-7-1)"

Extra space where? My SQL query its the following, I see it has the spaces. Maybe I am not understanding you.

Like this :

msg.topic = "INSERT INTO Andadores (ID_and,ID_pac,Inicio)"+ " VALUES ("+id_and+","+idpacs+","+inicio+")";
return msg;

the space outside the " " doesnt count

an even cleaner syntax is this .. using backticks ` .. not to be confused with single quotes '

msg.topic = `INSERT INTO Andadores (ID_and,ID_pac,Inicio) VALUES (${id_and},${idpacs},${inicio})`;

Thanks!
But no, it does not work. The issue its:

idpacs = idpacs.payload[0];

If I donĀ“t use that, then it returns the message to the output but well, the value its the object Object thing that is ruining it.

Thing is, I have used that line outside the flow Im trying to make work and it access to the value ID_pac, which is the goal. I donĀ“t know what is happening.

i thought it should have been

idpacs = idpacs.payload[0].ID_pac   // here

what did you try ?
because in the simulation it works

I have found the solution.

var idpacs = flow.get("flow");
idpacs = idpacs[0].ID_pac;

Once you store the context variable in the variable, you no longer need the .payload because now its called idpacs... I have been trying it in an independent flow to check what was happening until I realised it.

Thansk for the help. This was driving me crazy.

cool .. im glad you found it

im not sure if you know this but if you want to check your context ..
you go in the upper top right corner triangle and choose Context Data and refresh for the 'Flow'

Screenshot_2020-08-21 Node-RED 192 168 1 160

No I didnĀ“t know it..itĀ“s my first time doing this. Thanks!!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.