Output order dynamically

Hello,
I have a flow with 2 outputs going out of Node RED which are set at the same time. The call order is important for the outer system.
I can controll the order statically by changing positions. Maybe its also controllable by order of the return object.
But how can I control this dynamically?

Thank you

Without knowing a little more about your flow, this is impossible to answer. How are you outputting the msgs? What nodes are you using?

a image of your flow would help as would a copy of the flow

Q1


The flow is quite primitive. Depening how I arrange the outNodes on the paper they get called prior or not. I want to control and change which outputs fires fires first programatically.
Duplicating the output number of the function node is also static.

Q2
I did also an experiment with multiple messages:

var msg1 = { payload:"first out of output 1" };
var msg2 = { payload:"second out of output 1" };

var msg3 = { payload:"only message from output 2" };
return [ [ msg1, msg2], msg3 ];

This works as expected. Now I want to have msg3 come in between msg1 and msg2. How would I do this?

Thanks a lot

If you set the function node to have two outputs, you will see msg1 and 2 come out of one output and msg3 come out of the other and msg1+2 would go down one leg of the flow while msg3 would go downtime other.

You could use ajoin node (in manual configuration) to order the msgs and then run it thru a split to get the msgs in the order you want.

1 Like

As @zenofmud said, set function node to have 2 outputs.

Then use node.send to ensure order.

node.send([msg1,null]);
node.send([null,msg3]);
node.send([msg2,null]);
return null;
2 Likes

thanks, that helped

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