# Global variable changing content when setting sn instance of the global variable content

**URL:** <https://discourse.nodered.org/t/global-variable-changing-content-when-setting-sn-instance-of-the-global-variable-content/3822>\
**Category:** FAQs\
**Created:** [9 October 2018 14:09 UTC](https://discourse.nodered.org/t/global-variable-changing-content-when-setting-sn-instance-of-the-global-variable-content/3822 "2018-10-09T14:09:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josep](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@Josep](https://discourse.nodered.org/u/Josep)\
**Post date:** [9 October 2018 14:09 UTC](https://discourse.nodered.org/t/global-variable-changing-content-when-setting-sn-instance-of-the-global-variable-content/3822/1 "2018-10-09T14:09:13Z")

</div>

0down vote[favorite](https://stackoverflow.com/questions/52718962/global-value-changing-content-when-setting-another-variable-with-the-global-vari#)

If you look at the following example you could see that I'm setting a global value on startup. After that, If you click inject module you'll see that I set to `22` the `tag_id` attribute of the object on a new value. I don't understand why the global object changes the `tag_id` value to `22` if I'm setting the value in another variable. I don't want that the global value change.

```auto
[{"id":"a1dc09e7.208b48","type":"function","z":"81ac975c.542c88","name":"","func":"var o = global.get(\"machine\");\nnode.warn(o[1]);\no[1].tag_id = 22;\n\n","outputs":1,"noerr":0,"x":350,"y":320,"wires":[[]]},{"id":"4cca337d.f22bfc","type":"inject","z":"81ac975c.542c88","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"5","x":140,"y":320,"wires":[["a1dc09e7.208b48"]]},{"id":"fd1f90c5.86b85","type":"inject","z":"81ac975c.542c88","name":"Startup","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":140,"y":220,"wires":[["950e20e9.dd2d3"]]},{"id":"950e20e9.dd2d3","type":"function","z":"81ac975c.542c88","name":"","func":"msg ={\n\t\"1\": {\n\t\t\"timestamp\": \"\",\n\t\t\"tag\": \"\",\n\t\t\"tag_id\": 0,\n\t\t\"value\": 0,\n\t\t\"units\": \"\"\n\t}\n}\n\nglobal.set(\"machine\",msg);\n\n//return msg; ","outputs":1,"noerr":0,"x":350,"y":220,"wires":[[]]}]

```

---

<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:** [9 October 2018 14:35 UTC](https://discourse.nodered.org/t/global-variable-changing-content-when-setting-sn-instance-of-the-global-variable-content/3822/2 "2018-10-09T14:35:32Z")

</div>

Hi - the #development:feature-requests category isn't really appropriate for this question, so I've moved to #faqs

I've already answered this on StackOverflow - [https://stackoverflow.com/a/52723298/2117239](https://stackoverflow.com/a/52723298/2117239)
