How to get global variable properties

Hi guys, I working on my device and I have doubts how to working with context global variable object properties. You can see bellow my global context variable:

My global variable object and properties

I was use this function code to get object property storage on global variable, but I don´t know how to read for example, the property nwk_addr and the value storage (528b).

 var ext_addr = global.get ("00137a0000009a99");
 msg.payload = ext_addr;
 return msg;

When I using the unique id (ext_addr = 00137a0000009a99) I receiving all properties, as you can see bellow. How to I can filter only one specific property for each unique id?

Someone can help me, please?

How did you set the global variable ?


For your question:

msg.payload =

note that when you hover your mouse behind the properties you see 2 icons; the first is: copy path, this you can use to eliminate writing the path yourself.

As @bakman2 suggests the debug window can help you here.
There’s a page in the docs “working with messages” that’s worth a read.

How to navigate javascript objects is very important one Node-RED so it is also worth working through one of the many tutorials you will find online

Hi bakman2 thanks a lot. I got success after you advise me how to do it!

I set it up like this:

 "properties":properties}, "memoryOnly");

I used:

 var ext_addr = global.get("00137a0000009a99");
 msg.payload =;
 return msg;

Thanks a lot!
Best Regards,

Hi ukmoose,
I read this page, but I could not develop well after that.


Hi Guys, I working very well using a global variable in the memory, but i found problem in those variables after rpi3 reboot, the object properties disappeared (undefined) as can see below:


I storage it in the memory using this code:

  var unique = String(;
    var Epcount = global.get('EP_Count');
    var prop1 = global.get('nwk_addr1');
    var prop2 = global.get('nwk_addr2');
    var prop3 = global.get('ZDP_EP1');
    var prop4 = global.get('ZDP_EP2');
    var prop5 = global.get('attr.str');
    var prop6 = global.get('ext_addr1');
    var prop7 = global.get('ext_addr2');
    var prop8 = global.get('ext_addr3');
    var prop9 = global.get('ext_addr4');
    var prop10 = global.get('ext_addr5');
    var prop11 = global.get('ext_addr6');
    var prop12 = global.get('ext_addr7');
    var prop13 = global.get('ext_addr8');

if (Epcount ==1) {
        switch (prop5) {
            case 'ZBHT-2':{
                    var properties = {
                    "nwk_addr": prop1+prop2,
                    "Type":"Netvox Thermometer"

Someone have idea how to fix it?

Best Regards,

show us how you are setting the variables rather than getting them.

You will see that some are listed as “memory only” which is why they disappear on restart (as described in the docs)

Hi unkmosse, thanks!
do you can share with me a doc or article to explain how to get global variable in the file, similar i did in the memory?

Best Regards,

Maybe reading this thread will help you A guide to understanding 'Persistent Context'

1 Like

HI zenofmud, thanks a lote. I already read this tutorial. But, it served for me to define how to set global variables in the memory or file.
I tried to get a global variable storage in file using:
var nwk_add = global.get('nwk_addr1',"file") but is not working.

I have success to get the object propertites just using global variable in the memory. As you can see above i have object storage in the memory and file!
Do you give me help to undertanding it well?

Best Regards,

I don't see where in the link posted it says to use that syntax for global.get()

What did you set in settings.js to define it would be saved in storage?

So sorry for my mistake. I was defined to get global variable in the file in the wrong node position. Now is working very well..

var device = global.get("00137a000000a3bc","file");

Best Regards,

Sorry Colin!


Unfortunately, this code does not work.
What's wrong with me? What should I change to work?
The value of the two global variables is okay for it normally!

Hi @SwissAirplane

If you want to share code in the forum, its much easier if you copy and paste the code rather than take a screenshot.

Your syntax is not right. global.get is a function, so you should use () not []:

var temp = global.get("temptest");
var hum = global.get("humtest");

Looking at the rest of your code, you are not using those variables anywhere.

You do set msg.payload.svalue to the string "temp;hum;0" - did you mean for temp and hum in that string to be replaced by the values of those variables?

If so, you could use JavaScript string templates:

"svalue": `${temp};${hum};0`

or simple string concatenation:

"svalue": temp + ";" + hum + ";0"