# Quick Function node question

**URL:** <https://discourse.nodered.org/t/quick-function-node-question/45358>\
**Category:** General\
**Created:** [8 May 2021 10:10 UTC](https://discourse.nodered.org/t/quick-function-node-question/45358 "2021-05-08T10:10:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [8 May 2021 10:10 UTC](https://discourse.nodered.org/t/quick-function-node-question/45358/1 "2021-05-08T10:10:03Z")

</div>

In previous versions of Node-Red In a function node I could have if (msg.payload) { Do Something so any and all payloads would trigger Do Something however it no longer works what can I do instead.?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [8 May 2021 10:21 UTC](https://discourse.nodered.org/t/quick-function-node-question/45358/2 "2021-05-08T10:21:13Z")

</div>

Hi.

There has been no change to node red function node that would cause that to happen

It is more likely your payload is empty or there is an error in your function.

Have you checked the content of msg.payload going into the function by attaching a debug node BEFORE the function?

Could you share a small flow that demonstrates your issue?

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [8 May 2021 10:52 UTC](https://discourse.nodered.org/t/quick-function-node-question/45358/3 "2021-05-08T10:52:55Z")

</div>

Yes your right, my mistake, there was a error in my function node, nothing to do with the following example which demonstrates what I was trying to do, the error was in the code after this.

```auto
[{"id":"dc72f0ac.b098f","type":"inject","z":"4099862a.1f46b8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Anything","payloadType":"str","x":750,"y":1210,"wires":[["14c4a482.a7a86b"]]},{"id":"14c4a482.a7a86b","type":"function","z":"4099862a.1f46b8","name":"","func":"context.set('count', context.get('count')||0);\nvar count = context.get('count');\nvar shaper;\nif(msg.payload){\n if (count===0){\n count=1;\n context.set('count',count);\n shaper=\"ring\";\n }else{\n count=0;\n context.set('count',count);\n shaper=\"dot\";\n } \n} \n\n// actual function code\n\n\nnode.status({fill:\"red\",shape:shaper,text:msg.payload}); \n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":900,"y":1210,"wires":[[]]}]

```

---

<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:** [22 May 2021 10:53 UTC](https://discourse.nodered.org/t/quick-function-node-question/45358/4 "2021-05-22T10:53:38Z")

</div>

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