Quick Function node question

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.?

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?

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.

[{"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":[[]]}]

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