# Function Node split message to more outputs

**URL:** <https://discourse.nodered.org/t/function-node-split-message-to-more-outputs/10560>\
**Category:** General\
**Created:** [25 April 2019 19:49 UTC](https://discourse.nodered.org/t/function-node-split-message-to-more-outputs/10560 "2019-04-25T19:49:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hunterhb](https://avatars.discourse-cdn.com/v4/letter/h/a3d4f5/32.png) [@hunterhb](https://discourse.nodered.org/u/hunterhb)\
**Post date:** [25 April 2019 19:49 UTC](https://discourse.nodered.org/t/function-node-split-message-to-more-outputs/10560/1 "2019-04-25T19:49:04Z")

</div>

Hi Node-Red forum members,

I'm a german Node-Red beginner.  
I read this topic again and again, but can't solve my problem.  
[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

I want to split a Database result in different outputs from a function node.

The database query works:

25.4.2019, 21:21:26[node: 6acfe7c1.46d2c8](http://192.168.178.45:1880/#)SELECT \* FROM `tb_Pool_Variables` : msg : Object

object

\_msgid: "763b500d.377b"

topic: "SELECT \* FROM `tb_Pool_Variables`"

payload: array[1]

0: object

Max\_Pool\_Temp: 30

Einschalthysterese: 6

Ausschalthysterese: 1

Now i try to seperate Max\_Pool\_Temp, Einschalthysterese and Ausschalthysterese to 3 outputs of an function node.  
I always get the message:  
Function tried to send a message of type number

Yes i want to send a message of type number?!?  
I tried to cast it to string, then i get the error message : Fuction tried to send a message of type String.

I would be very grateful if someone could help me.  
Please excuse my poor english.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [25 April 2019 19:55 UTC](https://discourse.nodered.org/t/function-node-split-message-to-more-outputs/10560/2 "2019-04-25T19:55:19Z")

</div>

Firstly, your English is fine. You really need to post your flow here so that we can have a look. It looks like you are trying to return just a number in your function but you need to return the message object!

---

<div class="post-metadata">

**Author:** ![hunterhb](https://avatars.discourse-cdn.com/v4/letter/h/a3d4f5/32.png) [@hunterhb](https://discourse.nodered.org/u/hunterhb)\
**Post date:** [25 April 2019 20:14 UTC](https://discourse.nodered.org/t/function-node-split-message-to-more-outputs/10560/3 "2019-04-25T20:14:07Z")

</div>

This is my Init-Flow:

Here i want to feed the Gauge - Elements with the database data of the temperatures.

 ![2019-04-25-220955_1364x768_scrot](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/57de1509cec10979766a54d1ba528b39e8f61e0a.png)

This is my seperate Values funtction node:

 ![2019-04-25-221253_1364x768_scrot](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/be92fe7e740780c40cae8cd0af4f4e6470c09e42.png)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [25 April 2019 20:20 UTC](https://discourse.nodered.org/t/function-node-split-message-to-more-outputs/10560/4 "2019-04-25T20:20:17Z")

</div>

There’s a page in the documentation that explains how you can use the debug output to  
identify the correct path to any item  
[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

Understanding javascript objects and arrays is critical to getting the most from Node-RED

---

<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:** [25 April 2019 20:44 UTC](https://discourse.nodered.org/t/function-node-split-message-to-more-outputs/10560/5 "2019-04-25T20:44:51Z")

</div>

The fundamental issue is that you must always return an object (ie a message), not just a value or string. Often what you want to do is return a message with a value in the payload, so you may want the return to be something like

```auto
return [{payload: msg.payload[0].Max_Pool_Temp}, {payload:....},{..}]

```
