# Problem with global.get - it keeps returning a null value

**URL:** <https://discourse.nodered.org/t/problem-with-global-get-it-keeps-returning-a-null-value/67243>\
**Category:** General\
**Tags:** function-node\
**Created:** [2 September 2022 05:32 UTC](https://discourse.nodered.org/t/problem-with-global-get-it-keeps-returning-a-null-value/67243 "2022-09-02T05:32:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gadget](https://avatars.discourse-cdn.com/v4/letter/g/dec6dc/32.png) [@gadget](https://discourse.nodered.org/u/gadget)\
**Post date:** [2 September 2022 05:32 UTC](https://discourse.nodered.org/t/problem-with-global-get-it-keeps-returning-a-null-value/67243/1 "2022-09-02T05:32:09Z")

</div>

I'm at a loss why this is happening.

I have a current global context "totalvalue" per this:  
 ![nr1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9ee28b79172f889f3613a365a79d79b0f3210280.jpeg)

I'm accessing the context in a function node per the simple example flow shown below :  
 ![nr2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a959c1085e9867006034ded716c973813279ab43.jpeg)

However this returns a null value for the global get, as the payload is always zero (per the expression "|| 0"). It never returns 46515.

Must be a rookie mistake but I'm pretty sure it looks correct. Don't know if it's relevant but this is the NR addon in home assistant.

EDIT: It looks like it fails if the context is stored in the filesystem. If it's in memory it works.How do I point the get function to the correct spot?

---

<div class="post-metadata">

**Author:** ![gadget](https://avatars.discourse-cdn.com/v4/letter/g/dec6dc/32.png) [@gadget](https://discourse.nodered.org/u/gadget)\
**Post date:** [2 September 2022 05:44 UTC](https://discourse.nodered.org/t/problem-with-global-get-it-keeps-returning-a-null-value/67243/2 "2022-09-02T05:44:37Z")

</div>

I'm an idiot. I need to use global.get('totalvalue','file').

Leaving this up in case some one else needs to refer to it 😃

---

<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:** [16 September 2022 05:45 UTC](https://discourse.nodered.org/t/problem-with-global-get-it-keeps-returning-a-null-value/67243/3 "2022-09-16T05:45:34Z")

</div>

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