# Ui template & global scope

**URL:** <https://discourse.nodered.org/t/ui-template-global-scope/1929>\
**Category:** Dashboard\
**Created:** [31 July 2018 13:37 UTC](https://discourse.nodered.org/t/ui-template-global-scope/1929 "2018-07-31T13:37:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![realjax](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/realjax/32/895_2.png) [@realjax](https://discourse.nodered.org/u/realjax)\
**Post date:** [31 July 2018 13:37 UTC](https://discourse.nodered.org/t/ui-template-global-scope/1929/1 "2018-07-31T13:37:59Z")

</div>

Hello,

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!

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [31 July 2018 13:40 UTC](https://discourse.nodered.org/t/ui-template-global-scope/1929/2 "2018-07-31T13:40:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![realjax](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/realjax/32/895_2.png) [@realjax](https://discourse.nodered.org/u/realjax)\
**Post date:** [31 July 2018 13:41 UTC](https://discourse.nodered.org/t/ui-template-global-scope/1929/3 "2018-07-31T13:41:43Z")

</div>

OK thanks, will do that then!

---

<div class="post-metadata">

**Author:** ![sanyok953](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sanyok953/32/8972_2.png) [@sanyok953](https://discourse.nodered.org/u/sanyok953)\
**Post date:** [3 June 2019 05:29 UTC](https://discourse.nodered.org/t/ui-template-global-scope/1929/4 "2019-06-03T05:29:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![realjax](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/realjax/32/895_2.png) [@realjax](https://discourse.nodered.org/u/realjax)\
**Post date:** [3 June 2019 06:23 UTC](https://discourse.nodered.org/t/ui-template-global-scope/1929/5 "2019-06-03T06:23:40Z")

</div>

Hi

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. 😊

---

<div class="post-metadata">

**Author:** ![Aklex1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aklex1/32/19306_2.png) [@Aklex1](https://discourse.nodered.org/u/Aklex1)\
**Post date:** [3 April 2020 16:54 UTC](https://discourse.nodered.org/t/ui-template-global-scope/1929/6 "2020-04-03T16:54:10Z")

</div>

> [@knolleary](#):
>
> 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.

how message you then pass to the ui\_template node and in the opposite direction
