# Multiple output of function node not working as shown

**URL:** https://discourse.nodered.org/t/multiple-output-of-function-node-not-working-as-shown/32173
**Category:** General
**Created:** [29 August 2020 06:10 UTC](https://discourse.nodered.org/t/multiple-output-of-function-node-not-working-as-shown/32173 "2020-08-29T06:10:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [29 August 2020 06:10 UTC](https://discourse.nodered.org/t/multiple-output-of-function-node-not-working-as-shown/32173/1 "2020-08-29T06:10:50Z")

</div>

As brief as possible:

```auto
[{"id":"3cc824ef.442dd4","type":"inject","z":"710ca09a.8302a8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":500,"y":990,"wires":[["44a42f6c.0772c8"]]},{"id":"44a42f6c.0772c8","type":"function","z":"710ca09a.8302a8","name":"Reboot?","func":"var msg1 = {\n payload:\"CLS\",topic:\"pifacelcd/ctl\"\n}\n\nnode.warn(msg1);\n\nvar msg2 = {\n payload:\"Do you want to@0,0\"\n}\nvar msg3 = {\n payload:\"REBOOT?@0,1\"\n}\nnode.send(null,msg1);\n\nnode.send(msg2,null);\n\nnode.send(msg3,null);\nflow.set(\"command\",\"REBOOTING\");\n\n//return;","outputs":2,"noerr":0,"x":783.3333129882812,"y":991.111083984375,"wires":[["8c9a970c.5773f","911ba349.33a4c8"],["70150b6f.86490c","3c156b80.045b5c"]]}]

```

I don't understand why I am not getting `msg1` out of the first output.  
I see `msg2` and `msg3` come out the second one.

The code complies with the requirements I see here:  
[multiple outputs](https://nodered.org/docs/user-guide/writing-functions#multiple-messages)

Where it gives an example:  
(though not exactly what I have.)

```auto
if (msg.topic === "banana") {
   return [null, msg];
} else {
   return [msg, null];
}

```

But demonstrates what I am doing.

Here is another (better?) example:

```auto
[{"id":"83b635df.a823d8","type":"function","z":"710ca09a.8302a8","name":"","func":"msg1 = {\n payload:\"Output 1\"\n}\nmsg2 = {\n payload:\"Output 2\"\n}\nnode.send(null,msg2)\n\nnode.send(msg1,null)\n\n","outputs":2,"noerr":0,"x":700,"y":1520,"wires":[["4327d036.334e48"],["d9a075d2.a3d0a8"]]},{"id":"e3f5cf41.8d96f","type":"inject","z":"710ca09a.8302a8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":490,"y":1520,"wires":[["83b635df.a823d8"]]},{"id":"4327d036.334e48","type":"debug","z":"710ca09a.8302a8","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":840,"y":1480,"wires":[]},{"id":"d9a075d2.a3d0a8","type":"debug","z":"710ca09a.8302a8","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":840,"y":1560,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [29 August 2020 06:16 UTC](https://discourse.nodered.org/t/multiple-output-of-function-node-not-working-as-shown/32173/2 "2020-08-29T06:16:24Z")

</div>

Ok, I'm an idiot.

The line should be:  
`node.send([null,msg2])`

That works.

Sorry.

---

<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: [12 September 2020 06:16 UTC](https://discourse.nodered.org/t/multiple-output-of-function-node-not-working-as-shown/32173/3 "2020-09-12T06:16:26Z")

</div>

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