# Returning TWO msg.payloads?

**URL:** <https://discourse.nodered.org/t/returning-two-msg-payloads/456>\
**Category:** General\
**Created:** [29 May 2018 00:06 UTC](https://discourse.nodered.org/t/returning-two-msg-payloads/456 "2018-05-29T00:06:26Z")\
**Posts on this page:** 4\
**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 May 2018 00:06 UTC](https://discourse.nodered.org/t/returning-two-msg-payloads/456/1 "2018-05-29T00:06:26Z")

</div>

New problem.

(Of course)

With new knowledge I am re-writing a lot of my flows to simplify things. Or so I hope.

I have a “node” that detects if things are good or bad.  
If good, all is … good.

If bad, it sends ONE message to wipe data from being displayed on Gauges and Charts.

And there is the problem.

To wipe a Gauge, I have to send it 0.  
To wipe a Chart I have to send it NULL.

To cut down on nodes and types of nodes, I have one.  
(Function block.)

```auto
if (msg.topic === 'RESET')
{
    //
    msg.payload = '0';
    return msg;
}
return msg;

```

I don’t know if I am getting “carried away” with this style of thinking or what, but please indulge me.

Alas that wipes Gauges, but not Charts (or graphs as I call them).  
They need a NULL.

Is it I shall have to make a second version of this that sends msg.payload = [] rather than 0, or can I send two payloads?  
Or make two outputs?

---

<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 May 2018 01:26 UTC](https://discourse.nodered.org/t/returning-two-msg-payloads/456/2 "2018-05-29T01:26:25Z")

</div>

Sorry, something is happening and it needs further investigation.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [29 May 2018 06:38 UTC](https://discourse.nodered.org/t/returning-two-msg-payloads/456/3 "2018-05-29T06:38:49Z")

</div>

You cannot return more than once from a function. Once you return the function stops.

The documentation covers how to send multiple messages from a function, as well as how to send messages without using `return`.

[https://nodered.org/docs/writing-functions](https://nodered.org/docs/writing-functions)

---

<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 May 2018 07:04 UTC](https://discourse.nodered.org/t/returning-two-msg-payloads/456/4 "2018-05-29T07:04:41Z")

</div>

True,

But I did get around it with the trigger node.

So the problem as it is/was have been resolved.
