# Question about template dashboard 2

**URL:** <https://discourse.nodered.org/t/question-about-template-dashboard-2/92194>\
**Category:** Dashboard\
**Tags:** dashboard-2\
**Created:** [6 October 2024 15:59 UTC](https://discourse.nodered.org/t/question-about-template-dashboard-2/92194 "2024-10-06T15:59:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcpaulo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pcpaulo/32/2971_2.png) [@pcpaulo](https://discourse.nodered.org/u/pcpaulo)\
**Post date:** [6 October 2024 15:59 UTC](https://discourse.nodered.org/t/question-about-template-dashboard-2/92194/1 "2024-10-06T15:59:08Z")

</div>

On template is it possible to use global variable? How i can define?

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [6 October 2024 16:14 UTC](https://discourse.nodered.org/t/question-about-template-dashboard-2/92194/2 "2024-10-06T16:14:01Z")

</div>

The dashboard lives at the other side of the pipe called the socket. That pipe is used to send and receive messages containing the needed data between server side and dashboard. End of story.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [6 October 2024 16:14 UTC](https://discourse.nodered.org/t/question-about-template-dashboard-2/92194/3 "2024-10-06T16:14:48Z")

</div>

You would copy the global variable to a message property prior to the template node.

---

<div class="post-metadata">

**Author:** ![hazymat](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hazymat/32/108159_2.png) [@hazymat](https://discourse.nodered.org/u/hazymat)\
**Post date:** [6 October 2024 17:07 UTC](https://discourse.nodered.org/t/question-about-template-dashboard-2/92194/4 "2024-10-06T17:07:27Z")

</div>

Yes you can use a global variable in a Dashboard 2.0 Template. It's the same as Dashboard 1. You'll need to push it into the incoming message though. So technically it's nothing to do with the template node at all.

1. Create a function node:

`msg.payload = global.get("myVariable")`

1. Feed that into a template node, and display it on the dashboard using normal means:

`{{msg.payload}}`

---

<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:** [5 November 2024 17:43 UTC](https://discourse.nodered.org/t/question-about-template-dashboard-2/92194/6 "2024-11-05T17:43:44Z")

</div>

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