Hi
I have the following flow which is read mac address from the database. Then there is a function node that works to checks the mac existence of the mac by using the if statement as shown in the code below. it's run an only first statement of if and ignore the rest in spite of they are true...
What I wanted is to check each condition then return the message.
The code inside the function node :
var i;
for (i=0 ;i< msg.payload.length;i++){
if (msg.payload[i].mac=="2D:60" ){
msg.payload=msg.payload ="aldo ";
msg.payload= {employee:msg.payload ,timestamp :new Date().toString (),status :"check in"};
return msg;
}
if (msg.payload[i].mac=="abc" ){
msg.payload=msg.payload ="james ";
msg.payload= {employee:msg.payload ,timestamp :new Date().toString (),status :"check in"};
return msg;
}}
it's run only the first "if" statement as shown in the output below.