Global context variables do not display in the Context Sidebar

I downloaded/installed Node-Red 0.19.3 and I am using Global Context in my flows. The Flow variables are showing, but the Global variables which are in use and working do not show up in the Global context window. I'm running Windows 10. Previous install was 0.18. How do I get the reference to the Global context variables I'm using. I would really like to use this feature in Node-Red.

Kind Regards,

Show us how to you use the context. Have you enabled presistable context storage? Share the flow. or logs or settings. Almost impossible to help otherwise.

So Let me understand, Does the Global Context variables only show in the Sidebar Context pane if they are persistent? Or should they show if they are there as Memory Global variables as well?

I was under the impression that the Global Context variables would display as well as the Flow Context variables, which in this case are working and displayed.

msg.EXPDATE=dtExdate1;
global.set('EXPDATE',dtExdate1);

I have variables which are set using the Change node as well which set a value from the msg.paylaod to the Global Context variable... all working.

And your global variables doesn't show up even after you refresh the panel?
image

msg.EXPDATE=dtExdate1;
global.set('EXPDATE',dtExdate1);

Where does dtExdate1 get set?

knolleary,

EXPDATE1 and EXPDATE2 are globals to keep 2 channels of different product information.
This script compares the values between 1 and 2 and updates an overall value for the oldest between the 2 units.

The code works. All values are there, but there is nothing on the Context Data Global. And yes I updated using the refresh, highlighted the node, refreshed after running the flows producing the results. Values are kept correctly after test data is changed between the 2 channels. Essentially, the code is fine and performs as expected, but there is no values to be seen in the Sidebar/Context/Global view. :disappointed:

Function Node:
var dtExdate1 = global.get('EXPDATE1');
var dtExdate2 = global.get('EXPDATE2');
var dtExdate = global.get('EXPDATE');
if (dtExdate2<=dtExdate1) {
if ((dtExdate>dtExdate2)||(dtExdate<dtExdate2)) {
msg.Result = "Date Code Change by Ch2";
}
msg.EXPDATE=dtExdate2;
global.set('EXPDATE',dtExdate2);
}
if (dtExdate1<=dtExdate2) {
if ((dtExdate>dtExdate1)||(dtExdate<dtExdate1)) {
msg.Result = "Date Code Change by Ch1";
}
msg.EXPDATE=dtExdate1;
global.set('EXPDATE',dtExdate1);
}
return msg;

that is correct...

In your code, you are expecting, that all your variables are initialized somewhere previously. Not initialized variables give undefined if you ask them from context. Then you compare those values by expecting them to be numeric values but that comparing then fails. So your code runs perfectly by never touching any global.set part of it.
You should give some initial values for your variables to make it work.
For example
var dtExdate1 = global.get('EXPDATE1') || 123;

OK, All I need to do is add the phrase at the end of the statement?

... || "value";

And this invokes the Global reference value to be shown on the Context Sidebar?

When the variables do have value they should show up. No? Because I am only assuming they should be in the sidebar when they have a value... They exist and contain correct content because I can retrieve them with other nodes.

Kind Regards,

hotNipi,
I have many examples in my flows of Global context variables set, defined by Change nodes. They have content, but nothing shows up in the Global Context sidebar. I'm simply asking if anyone can let me know how to expose a Global variable in the Global Context sidebar. So far I have not seen it work. I don't know what I must do in order to see it work, even if my expectations are unrealistic with my example. What is an example of something that does work? Please.

It should just work.

If you do global.set('foo','bar'); in a function node, then refresh the context sidebar you should see it. If that doesn't work, then there is something particular about your setup that is causing an issue - we'd have to try to debug that, but I'm not sure where to start.

Nick,
OK, that is happening conditionally in my code. I'll be sure and set the value unconditionally and see how that goes.

Thank you for your response.

Kind Regards,

added these nodes.
Inject to function

global.set('mynewvar','321');
return msg;

to change node to read value to msg.payload to debug node.

inject into change node to force the global value to the debug sidebar.
That works. The value "321" is shown.

[{"id":"5ee27347.e7ba1c","type":"debug","z":"5ba2fa41.05c4e4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1240,"y":220,"wires":[]},{"id":"b9915530.415c88","type":"inject","z":"5ba2fa41.05c4e4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":840,"y":220,"wires":[["4b9b2ff1.da74c"]]},{"id":"4b9b2ff1.da74c","type":"change","z":"5ba2fa41.05c4e4","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"mynewvar","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":220,"wires":[["5ee27347.e7ba1c"]]},{"id":"66de6000.7275a","type":"function","z":"5ba2fa41.05c4e4","name":"","func":"global.set('mynewvar','321');\nreturn msg;","outputs":1,"noerr":0,"x":1030,"y":260,"wires":[["4b9b2ff1.da74c"]]},{"id":"436415db.393974","type":"inject","z":"5ba2fa41.05c4e4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":860,"y":260,"wires":[["66de6000.7275a"]]}]

it does not populate the Global Context sidebar... The Flow variables I use do, Globals do not work...

This seems to be common misunderstanding how to "read out" the Change node interface. At least I remember there was topic about this.

This is correct way to write the incoming msg.payload to global context variable
image

I think this semantic puzzle affects most probably not native English speakers.

sure,
I'm pulling the value off of the Global Context in order to display it with the debug node...
I can set the value in the Global context this way... Should I need to?

Confused,
hp_apcc...

The flow you shared works perfectly for me. It sets the value in global context in the function node, and pulls it back into the message in the change node. Refreshing the context data sidebar shows the value.

Can I check... You are using the built in context sidebar and not the contrib-contextbrowser add on?

I just upgraded Node-RED. I am using the sidebar... on the right. Context tab. I have NOT installed the contrib-contextbrowser add on. This is Windows 10, and not Linux. This is after I upgraded, shut down, restarted the PC and Node-Red a bunch of times.

Perhaps a screenshot showing it not showing it might be helpful.

Indeed a screenshot from your outcomes would be helpful. I tested your flow and it works fine.

You can try the attached flow. It will display in the debug panel (not in the context sidebar) the global variables names stored in the context. I would love to see a screenshot of your outcome for this flow. See mine below.

I wonder if there is some other flow that is disturbing your understanding (perhaps deleting the global variable). I suggest to disable ALL the flow tabs and run only the testing flow.

[{"id":"2bd98e3b.151692","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"1e657f2.7b02c81","type":"debug","z":"2bd98e3b.151692","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":490,"y":200,"wires":[]},{"id":"47a43fff.c594a","type":"function","z":"2bd98e3b.151692","name":"","func":"global.set(\"aaa\",111);\nnode.warn(global.keys());\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":200,"wires":[["1e657f2.7b02c81"]]},{"id":"5e9c9361.f6ac4c","type":"inject","z":"2bd98e3b.151692","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":200,"wires":[["47a43fff.c594a"]]}]