Ui template & global scope


I am trying to access the global scope in a ui template (<script> var myVar = global.get("MyVariable"); </script> ) but that results in a 'global is not defined' error message. Can I access it there and if so, using what syntax? tia!

No, you cannot access it directly. The only way to do so would be to create a flow that copies a context property on to a message you then pass to the ui_template node.

OK thanks, will do that then!

Hello. Can you write any example of using this? Thanks.

1 Like


Just keep in mind that the code in the ui template runs on the client side (browser) and the global scope is defined on the server side (your node red server). Makes it very clear but I forgot about this simple rule. :blush:

1 Like

how message you then pass to the ui_template node and in the opposite direction