# Output order dynamically

**URL:** <https://discourse.nodered.org/t/output-order-dynamically/26224>\
**Category:** General\
**Created:** [7 May 2020 09:21 UTC](https://discourse.nodered.org/t/output-order-dynamically/26224 "2020-05-07T09:21:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Assi](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@Assi](https://discourse.nodered.org/u/Assi)\
**Post date:** [7 May 2020 09:21 UTC](https://discourse.nodered.org/t/output-order-dynamically/26224/1 "2020-05-07T09:21:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 May 2020 09:41 UTC](https://discourse.nodered.org/t/output-order-dynamically/26224/2 "2020-05-07T09:41:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Assi](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@Assi](https://discourse.nodered.org/u/Assi)\
**Post date:** [7 May 2020 18:41 UTC](https://discourse.nodered.org/t/output-order-dynamically/26224/3 "2020-05-07T18:41:10Z")

</div>

Q1

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/19180b922f1b3187e7a96139540941329608d830.png)  
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 May 2020 19:24 UTC](https://discourse.nodered.org/t/output-order-dynamically/26224/4 "2020-05-07T19:24:03Z")

</div>

> [@Assi](#):
>
> 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 ];

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 a`join` node (in manual configuration) to order the msgs and then run it thru a `split` to get the msgs in the order you want.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 May 2020 19:30 UTC](https://discourse.nodered.org/t/output-order-dynamically/26224/5 "2020-05-07T19:30:41Z")

</div>

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

Then use node.send to ensure order.

```auto
node.send([msg1,null]);
node.send([null,msg3]);
node.send([msg2,null]);
return null;

```

---

<div class="post-metadata">

**Author:** ![Assi](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@Assi](https://discourse.nodered.org/u/Assi)\
**Post date:** [8 May 2020 11:51 UTC](https://discourse.nodered.org/t/output-order-dynamically/26224/6 "2020-05-08T11:51:27Z")

</div>

thanks, that helped

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 May 2020 11:51 UTC](https://discourse.nodered.org/t/output-order-dynamically/26224/7 "2020-05-22T11:51:30Z")

</div>

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