# Funktion node with String msg

**URL:** <https://discourse.nodered.org/t/funktion-node-with-string-msg/16206>\
**Category:** General\
**Created:** [2 October 2019 16:12 UTC](https://discourse.nodered.org/t/funktion-node-with-string-msg/16206 "2019-10-02T16:12:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wsuess](https://avatars.discourse-cdn.com/v4/letter/w/53a042/32.png) [@wsuess](https://discourse.nodered.org/u/wsuess)\
**Post date:** [2 October 2019 16:12 UTC](https://discourse.nodered.org/t/funktion-node-with-string-msg/16206/1 "2019-10-02T16:12:12Z")

</div>

Hi to all,  
see below Function block  
Test 1.

if (msg.payload \<=0)  
{  
return "Pressure too low";  
} else {  
return[""];  
}  
Test 2.  
var msg1= "Pressure too low";  
if (msg.payload \<=0)  
{  
return msg1;  
} else {  
return[""];  
}

The else case is working!  
Result: Function tried to send a message of type string  
I can do a work around with the change node, but I would like do it complete in the function node  
Wolfgang

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [2 October 2019 16:17 UTC](https://discourse.nodered.org/t/funktion-node-with-string-msg/16206/2 "2019-10-02T16:17:01Z")

</div>

Please check the [documentation](https://nodered.org/docs/user-guide/writing-functions).

Function node should return `msg`  
Thus, you need to return something like:

```auto
return {payload:"Pressure too low"}

```

You can change it like:

```auto
if (msg.payload < 1){
    return {payload:"Pressure too low"};
} 

```

The else is not needed, unless you want to return something.

---

<div class="post-metadata">

**Author:** ![wsuess](https://avatars.discourse-cdn.com/v4/letter/w/53a042/32.png) [@wsuess](https://discourse.nodered.org/u/wsuess)\
**Post date:** [2 October 2019 16:20 UTC](https://discourse.nodered.org/t/funktion-node-with-string-msg/16206/3 "2019-10-02T16:20:33Z")

</div>

Yes, you are right! Sorry, but these is one of these days, where you should stop working and go home and drink a beer!  
Thanks for clear it up

---

<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:** [2 October 2019 16:25 UTC](https://discourse.nodered.org/t/funktion-node-with-string-msg/16206/4 "2019-10-02T16:25:01Z")

</div>

Cheers to that ! 🍻
