Multiple Messages on different outputs with delay

Help! I need to get output with delay for each msg.

var msg1 = { payload:"first out of output 1" };
var msg2 = { payload:"second out of output 1" };
var msg3 = { payload:"third out of output 1" };
var msg4 = { payload:"only message from output 2" };
return [ [ msg1, msg2, msg3 ], msg4 ];

Will it work like this :point_down:. Tried but didn't worked :man_shrugging:

var msg1 = { payload:"first out of output 1" };
var msg2 = { payload:"second out of output 1" };
var msg3 = { payload:"third out of output 1" };
var msg4 = { payload:"only message from output 2" };
[ 
    [ 
      setTimeout(function(){node.send(msg1);},1000), 
      setTimeout(function(){node.send(msg2);},2000), 
      setTimeout(function(){node.send(msg3);},3000) 
     ], 
      setTimeout(function(){node.send(msg4);},4000) 
];

Found one alternate with delay node. But I want to achieve it in function node.

try...

var msg1 = { payload:"first out of output 1" };
var msg2 = { payload:"second out of output 1" };
var msg3 = { payload:"third out of output 1" };
var msg4 = { payload:"only message from output 2" };
setTimeout(function(){node.send([msg1,null]);},1000), 
setTimeout(function(){node.send([msg2,null]);},2000), 
setTimeout(function(){node.send([msg3,null]);},3000) 
setTimeout(function(){node.send([null,msg4]);},4000) 

Though to be honest, this kinda misses the point of a visual flow designer and low-code!

Thankyou :+1:

This will help me organize my flows better :sweat_smile:

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