Hello. I am a little bit stuck trying to build a flow variable array inside a function. I need this variable to be flow or global so I can use it in other functions:
The function look like this
//add the values to the msg so they can be debugged and used later
quantity = msg.payload
var device_id = msg.topic.split("/");// split the whole topic to devicex ( untill /)
msg.payload = device_id[0];
msg.topic=`UPDATE pack_to_light SET Quantity = '${quantity}' WHERE Device = '${device_id[0]}'`
flow.set("individual_items",msg.payload);
node.warn(flow.individual_items)
return msg;
This function will be triggered multiple times (may vary). For example, if this function is gets triggered 3 times, every time its triggered I set a new payload value to it as such:
msg.payload = device_id[0];
I need to set this msg.payload to flow variable named "individual_devices". I have attempted to set "individual_devices" to msg.payload but I cant figure out how do I build array out of it since I need the result to be something like that ( If function is triggered 3 times)
flow.individual_devices[0] = msg.payload1
flow.individual_devices[1] = msg.payload2
flow.individual_devices[2] = msg.payload3
In short, how can I keep track how many times the function did execute so I can create a variable length array for " individual_devices"