# Inject node only fires if msg.payload is defined?

**URL:** https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476
**Category:** General
**Created:** [31 March 2021 16:52 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476 "2021-03-31T16:52:26Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)
#### Post date: [31 March 2021 16:52 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/1 "2021-03-31T16:52:26Z")

</div>

Inject node only fires if msg.payload defined?

So, msg.payload as any value, inject node fires when clicked. But if msg.\* exists, but no msg.payload exits inject node does not fire. It is kind of a pain to add a change node to delete the payload, when you are just doing UI effects initialize, for example, enable/disable, color changes, etc., and the UI element is in pass-through mode, and should expect a payload other than initial message received for setup.

Another thought, would be nice if inject node could fire on context values as well, by the way. I often find I want to inject flow.\* (something), but have to setup a change node to grab the flow variable because inject can't directly.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [31 March 2021 17:16 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/2 "2021-03-31T17:16:49Z")

</div>

No, it works for me. What version of Node-RED?

---

<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: [31 March 2021 18:05 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/3 "2021-03-31T18:05:41Z")

</div>

> [@Nodi.Rubrum](#):
>
> I want to inject flow.\* (something), but have to setup a change node to grab the flow variable because inject can't directly.

Why not?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/1/0170f9c2930477d8a716183de1450a736f221efb.png)

If your inject node doesnt look like this ↑ you are probably on a much older node-red version.

---

<div class="post-metadata">

### Author: ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)
#### Post date: [1 April 2021 15:21 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/4 "2021-04-01T15:21:28Z")

</div>

Ah... was this implemented in 1.2.9? But my initial question still stands... inject node firing without msg.payload existing.

---

<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: [1 April 2021 15:31 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/5 "2021-04-01T15:31:47Z")

</div>

> [@Nodi.Rubrum](#):
>
> Ah... was this implemented in 1.2.9?

No, Version 1.1 released 30 June 2020

> **[Inject node properties - Version 1.1 released](https://nodered.org/blog/2020/06/30/version-1-1-released#inject-node-properties)**
>
> Node-RED 1.1 is now available to install. | Find out more on the blog

Havent ran V1.1.x in over 9 months so cant say.

could be a bug with a specific version you have (you didnt say which version you are running)

Can you not upgrade?

---

<div class="post-metadata">

### Author: ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)
#### Post date: [1 April 2021 15:38 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/6 "2021-04-01T15:38:47Z")

</div>

Moving to 1.2.9... just have not gotten all the Pi devices to it. 🙂 Most of my Pi Zeros are 1.0.6.

---

<div class="post-metadata">

### Author: ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)
#### Post date: [1 April 2021 22:25 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/7 "2021-04-01T22:25:45Z")

</div>

Don't feel so bad. I'm still running v0.18.4 on about 20 of the pi's in a industrial setting monitoring temps. They have one job and they do it well .... aint going to muck with it 😛

![pi-version](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/956e4cf900e8f052b48998b2bdea74d92057e34d.jpeg)

---

<div class="post-metadata">

### Author: ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)
#### Post date: [1 April 2021 23:44 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/8 "2021-04-01T23:44:54Z")

</div>

LOL! Yeah, I have about 10, and just for home automation and fun stuff... No real production... But what a PITA it is to update. I even automated the update so it is just a one click process. But I still seems to take forever to do it.

---

<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: [2 April 2021 12:36 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/9 "2021-04-02T12:36:56Z")

</div>

> [@Nodi.Rubrum](#):
>
> my initial question still stands... inject node firing without msg.payload existing.

Yes, with the current version you can inject an empty message. It will just contain the msg id.

---

<div class="post-metadata">

### Author: ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)
#### Post date: [2 April 2021 17:25 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/10 "2021-04-02T17:25:16Z")

</div>

Cool... nice. Looks like time update everything to 1.2.9 now.

---

<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: [1 June 2021 17:25 UTC](https://discourse.nodered.org/t/inject-node-only-fires-if-msg-payload-is-defined/43476/11 "2021-06-01T17:25:31Z")

</div>

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