# How to send a \`null\` from a \`trigger\` node?

**URL:** <https://discourse.nodered.org/t/how-to-send-a-null-from-a-trigger-node/12634>\
**Category:** General\
**Created:** [26 June 2019 21:52 UTC](https://discourse.nodered.org/t/how-to-send-a-null-from-a-trigger-node/12634 "2019-06-26T21:52:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 June 2019 21:52 UTC](https://discourse.nodered.org/t/how-to-send-a-null-from-a-trigger-node/12634/1 "2019-06-26T21:52:32Z")

</div>

I am wanting to inject a message of `null` to wipe my graphs/gauges.

But to make it a bit nicer I first want to send a `0` value to ...... (what ever) and then send the `null` to have them indicate they were told to _turn off_.

That is where the `trigger` node comes into the picture.

How do I get it to send `null` as the second message?

Ok, that may be nice to know, but I now realise that isn't exactly what I was wanting.

I am wanting the message payload to be `[]` - as I now see that `[]` is different to `null`.

---

<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:** [26 June 2019 22:10 UTC](https://discourse.nodered.org/t/how-to-send-a-null-from-a-trigger-node/12634/2 "2019-06-26T22:10:30Z")

</div>

Select JSON and send `[]`

As for sending null, you could a function node after the inject that sets msg.payload = null;

Probably possible with a change node too.

May even be possible with jsonata on the inject? Is JSON expression available on the inject node? I forget!

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 June 2019 22:14 UTC](https://discourse.nodered.org/t/how-to-send-a-null-from-a-trigger-node/12634/3 "2019-06-26T22:14:35Z")

</div>

Yes it is.

This is the flow on which I am working.

It is a mess, but that's because of the `trigger` node not playing the game.

```auto
[{"id":"d894ce7c.7fca88","type":"ui_gauge","z":"b74f6bef.ade128","name":"","group":"a3add0d4.f3ce7","order":4,"width":"4","height":"3","gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":770,"y":3380,"wires":[]},{"id":"d6d252ac.e4a67","type":"ui_chart","z":"b74f6bef.ade128","name":"","group":"a3add0d4.f3ce7","order":5,"width":"4","height":"3","label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"No comms","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":770,"y":3420,"wires":[[]]},{"id":"4b1ea411.1ceea4","type":"inject","z":"b74f6bef.ade128","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":3380,"wires":[["e1685970.6417b8","4f0551bf.e9dc7"]]},{"id":"e1685970.6417b8","type":"trigger","z":"b74f6bef.ade128","op1":"8","op2":"[]","op1type":"num","op2type":"str","duration":"3","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":430,"y":3380,"wires":[["d894ce7c.7fca88","d6d252ac.e4a67"]]},{"id":"653949a7.d218a8","type":"trigger","z":"b74f6bef.ade128","op1":"8","op2":"[]","op1type":"num","op2type":"str","duration":"4","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":430,"y":3340,"wires":[["411548bb.9fff18"]]},{"id":"411548bb.9fff18","type":"function","z":"b74f6bef.ade128","name":"","func":"msg.payload = [];\nmsg.topic = \"something\";\nreturn msg;","outputs":1,"noerr":0,"x":560,"y":3340,"wires":[["c20aa324.08e85","d6d252ac.e4a67","d894ce7c.7fca88"]]},{"id":"c20aa324.08e85","type":"function","z":"b74f6bef.ade128","name":"","func":"if (msg.payload.length === 0 )\n{\n node.warn(\"Null payload detected\");\n msg.payload = \"N/C\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":690,"y":3340,"wires":[["d894ce7c.7fca88"]]},{"id":"4f0551bf.e9dc7","type":"delay","z":"b74f6bef.ade128","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":280,"y":3340,"wires":[["653949a7.d218a8"]]},{"id":"a3add0d4.f3ce7","type":"ui_group","z":"","name":"Mark","tab":"e5699c6d.5d7e8","order":1,"disp":false,"width":"12","collapse":false},{"id":"e5699c6d.5d7e8","type":"ui_tab","z":"","name":"Events","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

```

There should be an easier way.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 June 2019 22:17 UTC](https://discourse.nodered.org/t/how-to-send-a-null-from-a-trigger-node/12634/4 "2019-06-26T22:17:13Z")

</div>

> [@Steve-Mcl](#):
>
> Select JSON and send `[]`

I think the space between the `[` and the `]` threw me. Progress has been made. But not to conclusion.

Still stuck with the flow.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 June 2019 22:30 UTC](https://discourse.nodered.org/t/how-to-send-a-null-from-a-trigger-node/12634/5 "2019-06-26T22:30:21Z")

</div>

Got it!

This works.

```auto
[{"id":"d894ce7c.7fca88","type":"ui_gauge","z":"b74f6bef.ade128","name":"","group":"a3add0d4.f3ce7","order":4,"width":"4","height":"3","gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":570,"y":3400,"wires":[]},{"id":"d6d252ac.e4a67","type":"ui_chart","z":"b74f6bef.ade128","name":"","group":"a3add0d4.f3ce7","order":5,"width":"4","height":"3","label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"No comms","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":570,"y":3460,"wires":[[]]},{"id":"4837c5a8.e6de54","type":"function","z":"b74f6bef.ade128","name":"","func":"if (msg.payload.length === 0 )\n{\n node.warn(\"Null payload detected\");\n msg.payload = \"N/C\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":3400,"wires":[["d894ce7c.7fca88","d6d252ac.e4a67"]]},{"id":"c985eea9.9264d","type":"inject","z":"b74f6bef.ade128","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":3460,"wires":[["5bb5f108.85885"]]},{"id":"5bb5f108.85885","type":"trigger","z":"b74f6bef.ade128","op1":"8","op2":"[]","op1type":"num","op2type":"json","duration":"3","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":330,"y":3460,"wires":[["4837c5a8.e6de54"]]},{"id":"a3add0d4.f3ce7","type":"ui_group","z":"","name":"Mark","tab":"e5699c6d.5d7e8","order":1,"disp":false,"width":"12","collapse":false},{"id":"e5699c6d.5d7e8","type":"ui_tab","z":"","name":"Events","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

```
