# I'm missing something with the inject node and the { } optoin

**URL:** <https://discourse.nodered.org/t/im-missing-something-with-the-inject-node-and-the-optoin/868>\
**Category:** General\
**Created:** [17 June 2018 05:33 UTC](https://discourse.nodered.org/t/im-missing-something-with-the-inject-node-and-the-optoin/868 "2018-06-17T05:33:29Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [18 June 2018 22:26 UTC](https://discourse.nodered.org/t/im-missing-something-with-the-inject-node-and-the-optoin/868/21 "2018-06-18T22:26:03Z")

</div>

Some of this could be avoided if the red box did not show up on initial display of a new node with an empty JSON string…

---

<div class="post-metadata">

**Author:** ![asandford](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@asandford](https://discourse.nodered.org/u/asandford)\
**Post date:** [18 June 2018 22:27 UTC](https://discourse.nodered.org/t/im-missing-something-with-the-inject-node-and-the-optoin/868/22 "2018-06-18T22:27:36Z")

</div>

Ok, thanks. I didn’t realise the border colour was significant…

---

<div class="post-metadata">

**Author:** ![asandford](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@asandford](https://discourse.nodered.org/u/asandford)\
**Post date:** [18 June 2018 22:30 UTC](https://discourse.nodered.org/t/im-missing-something-with-the-inject-node-and-the-optoin/868/23 "2018-06-18T22:30:54Z")

</div>

msg.background isn’t being set, msg.payload.background is.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [18 June 2018 22:37 UTC](https://discourse.nodered.org/t/im-missing-something-with-the-inject-node-and-the-optoin/868/24 "2018-06-18T22:37:55Z")

</div>

> [@Trying\_to\_learn](#):
>
> It is understood by me that if I send a … package (?) to a button with msg.background set to a valid value and in the button have the background colour option set to {{msg.background}} when the package arrives the background colour will change to said colour.

Message. You pass Messages between nodes. Not Package. Message.

The Inject node in the flow you've shared is setting `msg.payload` to the value `{"payload":"","background":"red"}`

That means `msg.payload` has that whole value. It is not setting `msg.payload` and `msg.background`.

The Inject node can **only** set `msg.payload` and `msg.topic`. I've said that twice already and I really cannot make that any clearer. It can **only** set those two properties.

If you want to set `msg.background` you need to use a `Change` node. You **cannot** do that with just an Inject node.

Here is a flow with the Change node added to set `msg.background`.

````auto
[{"id":"9124b7ee.b1e3d8","type":"ui_button","z":"1afd08.80e012f8","name":"","group":"77481625.d282a8","order":0,"width":0,"height":0,"passthru":false,"label":"button","color":"","bgcolor":"","icon":"","payload":"{\"payload\":\"\",\"background\":\"red\"}","payloadType":"json","topic":"","x":210,"y":260,"wires":[["92b1160e.cd2f58"]]},{"id":"92b1160e.cd2f58","type":"ui_button","z":"1afd08.80e012f8","name":"","group":"7f2f9e09.f95f5","order":0,"width":0,"height":0,"passthru":true,"label":"victim","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":590,"y":260,"wires":[["9b20671e.080c38"]]},{"id":"74e738da.4d6a08","type":"inject","z":"1afd08.80e012f8","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":180,"wires":[["bc5ff804.f184e8","5208f931.e3ab98"]]},{"id":"bc5ff804.f184e8","type":"debug","z":"1afd08.80e012f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":420,"y":180,"wires":[]},{"id":"9b20671e.080c38","type":"debug","z":"1afd08.80e012f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":710,"y":260,"wires":[]},{"id":"5208f931.e3ab98","type":"change","z":"1afd08.80e012f8","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":220,"wires":[["92b1160e.cd2f58"]]},{"id":"77481625.d282a8","type":"ui_group","name":"Group 1","tab":"f8e4161b.b12b68","order":1,"disp":true,"width":6},{"id":"7f2f9e09.f95f5","type":"ui_group","name":"Group 2","tab":"f8e4161b.b12b68","order":2,"disp":true,"width":6},{"id":"f8e4161b.b12b68","type":"ui_tab","z":"","name":"Colour test","icon":"dashboard","order":5}]```
````

---

<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:** [18 June 2018 22:38 UTC](https://discourse.nodered.org/t/im-missing-something-with-the-inject-node-and-the-optoin/868/25 "2018-06-18T22:38:50Z")

</div>

Um, ok.

But I’m easily confused.

Though knollearly has told me (time and again) that the INJECT node can’t do it and I should have listened - and it isn’t to have any disrespect for what he says - your reply was taken as:  
“Oh, you can do what you ORIGINALLY ASKED by doing this…”

And so I STUPIDLY believed that what you posted would set msg.background to “red”.

Yes, it was/is written in the code - had I actually read it - but how you replied threw me for believing that what you posted fitted my original request.

I really have to learn to read. but sorry, your reply didn’t help my confusion.

---

<div class="post-metadata">

**Author:** ![asandford](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@asandford](https://discourse.nodered.org/u/asandford)\
**Post date:** [18 June 2018 22:58 UTC](https://discourse.nodered.org/t/im-missing-something-with-the-inject-node-and-the-optoin/868/26 "2018-06-18T22:58:30Z")

</div>

I think you need to read up on objects. They can be quite hard to get your head around, but once things become clear, it’s not as obtuse.

msg is an object, think of a car object:

it has values (car.wheels:4, car.transmision:automatic, car.colour:red) and it has methods (functions) that do things (update a property value or run code)

[Previous page](https://discourse.nodered.org/t/im-missing-something-with-the-inject-node-and-the-optoin/868.md?page=1)
