# Send 2 messages to 2 functions

**URL:** https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126
**Category:** General
**Created:** [5 May 2020 11:19 UTC](https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126 "2020-05-05T11:19:01Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![fogmajor](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@fogmajor](https://discourse.nodered.org/u/fogmajor)
#### Post date: [5 May 2020 11:19 UTC](https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126/1 "2020-05-05T11:19:01Z")

</div>

Good morning  
I wonder if someone would be kind enough to point me in the right direction please.

I have a flow that uses a function to decide on what action to carry out  
After it has run through the logic it creates a message and sends to a insert data into a sql database  
and a second message to a UDP device

Many thanks  
Andrew

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/1/615ac50f1f4c4798f01c16bbe9dbd7ca693eb9a8.png)

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [5 May 2020 11:20 UTC](https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126/2 "2020-05-05T11:20:25Z")

</div>

see the docs re multiple outputs - [https://nodered.org/docs/user-guide/writing-functions](https://nodered.org/docs/user-guide/writing-functions)

---

<div class="post-metadata">

### Author: ![fogmajor](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@fogmajor](https://discourse.nodered.org/u/fogmajor)
#### Post date: [5 May 2020 11:20 UTC](https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126/3 "2020-05-05T11:20:42Z")

</div>

Many thanks

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [6 May 2020 11:16 UTC](https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126/4 "2020-05-06T11:16:06Z")

</div>

In particular a Function node can have multiple outputs, so you can send one message to each.

---

<div class="post-metadata">

### Author: ![fogmajor](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@fogmajor](https://discourse.nodered.org/u/fogmajor)
#### Post date: [6 May 2020 12:16 UTC](https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126/5 "2020-05-06T12:16:05Z")

</div>

Thank you

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [6 May 2020 12:17 UTC](https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126/6 "2020-05-06T12:17:38Z")

</div>

Additionally, if your function would be as simple as an if statement with a condition similar to "msg = x", take a look at the `switch` node and see if you can use it 🙂

---

<div class="post-metadata">

### Author: ![fogmajor](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@fogmajor](https://discourse.nodered.org/u/fogmajor)
#### Post date: [6 May 2020 13:13 UTC](https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126/7 "2020-05-06T13:13:49Z")

</div>

Hi many thanks  
I have quite a complex function string a binary string but am struggling with the concept of multiple messages, I have created what i call a bodge where I use a change node, I guess I need to understand the payload part of node-red a little better

Andrew

---

<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: [5 July 2020 13:13 UTC](https://discourse.nodered.org/t/send-2-messages-to-2-functions/26126/8 "2020-07-05T13:13:53Z")

</div>

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