# Global Variable to format Value/Label fields of ui-nodes

**URL:** <https://discourse.nodered.org/t/global-variable-to-format-value-label-fields-of-ui-nodes/49572>\
**Category:** Dashboard\
**Created:** [10 August 2021 14:42 UTC](https://discourse.nodered.org/t/global-variable-to-format-value-label-fields-of-ui-nodes/49572 "2021-08-10T14:42:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jodelkoenig](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jodelkoenig/32/44645_2.png) [@jodelkoenig](https://discourse.nodered.org/u/jodelkoenig)\
**Post date:** [10 August 2021 14:42 UTC](https://discourse.nodered.org/t/global-variable-to-format-value-label-fields-of-ui-nodes/49572/1 "2021-08-10T14:42:40Z")

</div>

I use HTML to format Value Format and Label of UI-nodes. F. e.

```auto
<font color = {{msg.color}} >Hallo</font>

```

msg.color is defined right before the ui-node in the corresponding flows.

I thought, I could globally set my color scheme and re-utilize it with global variables. However,

```auto
<font color = {{global.color_x}} >Hallo</font>

```

isn't recognized. The text is standard white. The same applies if I used global.get("color\_x") or global.get('color\_x') instead of global.color\_x.

I could not find any hint whether this approach in general isn't possible in relation to HTML. Everywhere else I can access global variables in function nodes or ...

Any hint would be highly appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [10 August 2021 15:32 UTC](https://discourse.nodered.org/t/global-variable-to-format-value-label-fields-of-ui-nodes/49572/2 "2021-08-10T15:32:15Z")

</div>

You should be using either CSS classes or style attributes.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [10 August 2021 15:32 UTC](https://discourse.nodered.org/t/global-variable-to-format-value-label-fields-of-ui-nodes/49572/3 "2021-08-10T15:32:41Z")

</div>

Hi @jodelkoenig,  
When you inject a msg into a UI template node, that msg is pushed to the dashboard. So you can use the msg properties like in your example.  
However the Node-RED (node/flow/global) memory context is only available on the server side flow. So it is normal that you can access those properties e.g. in a function-node, since the JS code (which you have entered inside the function node) is running on the server. But you don't have that data available in the dashboard.  
Bart

---

<div class="post-metadata">

**Author:** ![jodelkoenig](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jodelkoenig/32/44645_2.png) [@jodelkoenig](https://discourse.nodered.org/u/jodelkoenig)\
**Post date:** [10 August 2021 15:51 UTC](https://discourse.nodered.org/t/global-variable-to-format-value-label-fields-of-ui-nodes/49572/4 "2021-08-10T15:51:01Z")

</div>

Thanks @TotallyInformation. I know I can or better should do the same via CSS or style attributes. The solution with \< font color \>, however, was easy enough for me to grasp and implement at the time I started with nodered. I think, I should dig a bit into it 😃

I see and understand now, why global context is not working here, @BartButenaers . Thanks for your explanation. It makes sense 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 September 2021 15:51 UTC](https://discourse.nodered.org/t/global-variable-to-format-value-label-fields-of-ui-nodes/49572/5 "2021-09-09T15:51:30Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
