Global context probems

I have a need to access variables common to all flows, i am creating/setting the values in a dashboard flow devoted to ui and wish to access the values set (or their default) in flows that perform tests and stimulate further action conditionally.

when looking up how to do this i found Node context : Node-RED
but when i tried to declare variables in that format with the keyword 'this' i got errors, which led me to find posts on the google group suggesting that the node red functions page detailed everything i needed to know. so i have been back there, Redirecting…

which says

Global context

The global context can be pre-populated with objects when Node-RED starts. This is defined in the main settings.js file under the functionGlobalContext property.

So I dont Have to declare and predefine them in that file, i can just add a '||DefaultVal' suffix to my global.get()??

my recollection of the google trail is sketchy but i seem to recall reading that the page referring to the 'this' object was out of date, but the page it links to discusses release 0.19.. but its an official node red doc page??

so in my ui flow i am using
var P1MML = global.get('P1MML')||30;
global.set('P1MML',msg.payload);
return msg;

and in my other flows accessing the global
P1MML = global.get('P1MML')||30;

anything else needed???

OK, you have confused two different contexts. The first link is a reference to creating custom nodes. But then you talk about the function node.

In a function node, you have access to three types of variable. "context" is only available to that specific function node instance. "Flow" is only available to nodes in the "tab" in the admin ui that your node is in. Global is available to everything.

If you want to pre-populate a variable, you either have to trigger setting it when Node-RED starts or, but only for globals, you can pre-define it in the settings.js file. But you don't have to do that. As long as you allow in your flows for a global/flow/context variable to not yet existing, that's fine.

The first page is about creating you own node-red-contrib-nodes (contains creating-nodes within the URL) The second page is if you are writing functions or using the context settings within a change node (contains writing-functions within the URL).

in v0.19 there are different ways of storing context values which means they can be prepopulated.

Is the third page you read an official node-RED doc page? Well without the URL that would be tricky to answer

But what you have written should work, so have you tried it?

Im far from creating custom nodes, just embedding my global settings in some new code and things are not quite right and when checking on what i may have missed i found the above rabbit hole

time to pull thngs apart and test individually