# Inject number to Global

**URL:** <https://discourse.nodered.org/t/inject-number-to-global/67985>\
**Category:** General\
**Created:** [20 September 2022 17:04 UTC](https://discourse.nodered.org/t/inject-number-to-global/67985 "2022-09-20T17:04:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [20 September 2022 17:04 UTC](https://discourse.nodered.org/t/inject-number-to-global/67985/1 "2022-09-20T17:04:45Z")

</div>

Hi  
I tried to use an "inject" to global.Gas \> did not work  
I tried "change" msg.Gaszähler to the value global.Gas \> did not work  
I tried "function"`var Gas=msg.Gaszähler; flow.set("Gas",Gas);`  
that works, but I do not know to influence that it does not go into the memory by default but is saved as a file.  
Can anyone help me here?

---

<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:** [20 September 2022 17:15 UTC](https://discourse.nodered.org/t/inject-number-to-global/67985/2 "2022-09-20T17:15:36Z")

</div>

You cannot use inject, you can only get from global and add to the msg using inject.

You CAN use change.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/33aa7453678df010d5e5a15668253ce18e0c1a45.png)

for a function node, you need to use `global.set` not `flow.set`.

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [20 September 2022 18:55 UTC](https://discourse.nodered.org/t/inject-number-to-global/67985/3 "2022-09-20T18:55:20Z")

</div>

Thanks TotallyInform  
so i have change node the other way round.  
It's also a bit confusing when you read it.  
set global.gas to the value msg.payload.  
it should actually read dang:  
set global.gas to the value from msg.payload.  
Thank you

---

<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:** [21 September 2022 20:52 UTC](https://discourse.nodered.org/t/inject-number-to-global/67985/4 "2022-09-21T20:52:41Z")

</div>

> [@edstobi](#):
>
> it should actually read dang:  
> set global.gas to the value from msg.payload.

The algorithm to decide what to show would have to be quite complex. Consider: Set global.gas to the value from 7

---

<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:** [5 October 2022 20:53 UTC](https://discourse.nodered.org/t/inject-number-to-global/67985/5 "2022-10-05T20:53:27Z")

</div>

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