I have a function node with the Form node in front in DB2 and I would like to save it to global variable (global.set). But nothing happens … script is got from DB1, is there a possibility, that Form node put values different, but I don’t know why, because DB1 was uninstalled from my NR.
var userdata = [];
var read_data = global.get("userdata");
if (read_data){
userdata = read_data;
}
userdata.push({
id:String(msg._client.socketId),
ns:msg.payload.name_surname,
login:msg.payload.user_login,
pass:msg.payload.user_pass,
rights:msg.payload.user_rights
});
global.set("userdata",userdata);
msg.payload=userdata;
return msg;
Problem was identified after first wrong data entry into global.set. Next error rise up immediately after it. After deleting global variable, and change header Vars with if condition …. if is empty, create new, and if is not empty, add previous data and push new to this.
Thanks guys to correct direction and also to making me think about it.
Of course, thanks to this point. is Array is good solution.
I have changed it …. and working good. Thanks.
I think in global var will not “stay” any fail.