# Global get, set problem

**URL:** <https://discourse.nodered.org/t/global-get-set-problem/92702>\
**Category:** General\
**Created:** [26 October 2024 21:12 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702 "2024-10-26T21:12:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![GIGS1975](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gigs1975/32/47306_2.png) [@GIGS1975](https://discourse.nodered.org/u/GIGS1975)\
**Post date:** [26 October 2024 21:12 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/1 "2024-10-26T21:12:20Z")

</div>

Hello there  
I went through all the topics related to my problem, but unofrtunatelly i could not find the answer. I was looking for a solution, that allows me to save data that will survive restarts. So i have found that i need to change settings.js, and then use the localfilesystem storage for that purpose. So i have changed my settings,

contextStorage: {  
default: {  
module: "memory"  
},  
file: {  
module: "localfilesystem"  
}  
},

after that i restarted nodered. Next i used global.set("sheetevents", "file"), to store my data. After restart, i tried to read data by

global.get("sheetevents") and by global.get("sheetevents","file") too. Neither of them worked.

Strangely, in sidebar's ContextData i could find the sheetevents variable, stored as it was intended, but still no luck to use it in a function. Anyone any help please?

LITTLE UPDATE, in side context bar it also dissapiered after a refreshed the sidebar..

Now after another restart i am getting a warning

"Unknown context store 'file' specified. Using default store."

What am i missing?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [26 October 2024 21:38 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/2 "2024-10-26T21:38:56Z")

</div>

Have you modified the correct settings file, the location of the settings file is shown in the console at start up.  
If the correct file, show us the edited section, including a few lines before and after.  
Does the sidebar context show file as the context store for `sheetevent`

---

<div class="post-metadata">

**Author:** ![GIGS1975](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gigs1975/32/47306_2.png) [@GIGS1975](https://discourse.nodered.org/u/GIGS1975)\
**Post date:** [26 October 2024 21:51 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/3 "2024-10-26T21:51:52Z")

</div>

I hope i modified the correct one. Are there more settings files? I have found that in my user/nodered directory..The side bar doesnt show sheetevent after i refreshed it, so the problem originate probably from saving the value. The warning also inidicates, that nodered could not find the "file" storage,so he uses the default.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [26 October 2024 23:30 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/4 "2024-10-26T23:30:15Z")

</div>

Your settings for context storage are like this

> [@GIGS1975](#):
>
> contextStorage: {  
> default: { module: "memory" },  
> file: { module: "localfilesystem" }  
> },

while my settings.js has this, which works:

```auto
contextStorage: {
   default: "memoryOnly",
   memoryOnly: { module: 'memory' },
   file: { module: 'localfilesystem' }
},

```

Perhaps try changing your to match mine? "memoryOnly" and "memory" should both work.

ps If you use a change node to set a context variable, do you see the memory/file location dropdown?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/08c5371894f5fe0f02925eebbe4b4565e33ed212.png)

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

Don't be distracted by the icon always being a hard disk stack, it's the text - in dove grey on white, teeniest of fonts - that counts!

---

<div class="post-metadata">

**Author:** ![GIGS1975](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gigs1975/32/47306_2.png) [@GIGS1975](https://discourse.nodered.org/u/GIGS1975)\
**Post date:** [27 October 2024 07:34 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/5 "2024-10-27T07:34:02Z")

</div>

Hello  
Thanks for your suggestions, i will try to change the setting file.

This is what i see in change node

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

---

<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:** [27 October 2024 09:32 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/6 "2024-10-27T09:32:39Z")

</div>

> [@GIGS1975](#):
>
> I hope i modified the correct one. Are there more settings files?

Look at the node-red startup log to see which settings file it is using.

---

<div class="post-metadata">

**Author:** ![GIGS1975](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gigs1975/32/47306_2.png) [@GIGS1975](https://discourse.nodered.org/u/GIGS1975)\
**Post date:** [27 October 2024 10:01 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/7 "2024-10-27T10:01:19Z")

</div>

> [@jbudd](#):
>
> ```auto
> contextStorage: {
> default: "memoryOnly",
> memoryOnly: { module: 'memory' },
> file: { module: 'localfilesystem' }
> },
> 
> ```

It is the correct one. But i think the problem is with the fact, that nodered is running as service. So it is messing up things, and not using my settings file. I tried evey possible restart, no help.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [27 October 2024 10:47 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/8 "2024-10-27T10:47:26Z")

</div>

I don't use Node-red on Windows but I suspect the problem with this in C:\Users\<username\>.node-red\settings.js

```auto
contextStorage: {
   default: "memoryOnly",
   memoryOnly: { module: 'memory' },
   file: { module: 'localfilesystem' }
},

```

... is that the default is memoryOnly so _every time_ you want to refer to a filesystem context variable you must remember to select "file".

Or I suppose in your first flow tab you could copy your variables from filesystem to memory.

---

<div class="post-metadata">

**Author:** ![GIGS1975](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gigs1975/32/47306_2.png) [@GIGS1975](https://discourse.nodered.org/u/GIGS1975)\
**Post date:** [28 October 2024 08:07 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/9 "2024-10-28T08:07:59Z")

</div>

Hello guys  
Thanks for all of your helps  
We found the reason, and i am gonna share it with thouse running in my shoes  
The problem originates from Nodered beeing set up as a service...  
So in case it is running as a service, the settings file is not the same as it should be. It is cloning somehow the settings.js, and i was not able to find it. So we destroyed the process, and started using nodered regularly, and now i am able to use different storages.  
Thanks for every single effort to help me

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [28 October 2024 08:31 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/10 "2024-10-28T08:31:14Z")

</div>

I think you can declare the user directory in the service (at least if you are using NSSM as your service manager) in the arguments section with -u

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/02a0228a9b66cd968b8aa75bfe63163d169ac80d.png)

I run 8 instances of NR as service in the same machine with different settings file.

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

---

<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:** [28 October 2024 08:54 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/11 "2024-10-28T08:54:50Z")

</div>

> [@smanjunath211](#):
>
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/02a0228a9b66cd968b8aa75bfe63163d169ac80d.png)
> 
> I run 8 instances of NR as service in the same machine with different settings file.

Not a great idea to do this. Windows pipe locks the log file and it can never be rotated or delated and will eventually fill to a huge size.

Better to use the nssm built in logging options.

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

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

_Ignore the values on these random screenshots I borrowed from the internet - they are here only to show options avaiable_

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [28 October 2024 09:04 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/12 "2024-10-28T09:04:28Z")

</div>

good to know, but i have a scheduled task, with which i restart node red every week, and i dont have trouble with file size currently, but there is a scope for improvement sure.

---

<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:** [26 January 2025 09:04 UTC](https://discourse.nodered.org/t/global-get-set-problem/92702/13 "2025-01-26T09:04:46Z")

</div>

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