# Proper use of msg.template / controlling the execution of template node

**URL:** https://discourse.nodered.org/t/proper-use-of-msg-template-controlling-the-execution-of-template-node/57007
**Category:** Dashboard
**Created:** [21 January 2022 10:51 UTC](https://discourse.nodered.org/t/proper-use-of-msg-template-controlling-the-execution-of-template-node/57007 "2022-01-21T10:51:14Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![nico25](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nico25](https://discourse.nodered.org/u/nico25)
#### Post date: [21 January 2022 10:51 UTC](https://discourse.nodered.org/t/proper-use-of-msg-template-controlling-the-execution-of-template-node/57007/1 "2022-01-21T10:51:14Z")

</div>

After the user is logged-in im my dashboard I want a template to be executed, which changes the color of a tab in the sidebar. My problem: I´ve been trying to achieve this behaviour by sending the style properties in msg.template to the node, but it doesnt do anything.  
Here is what I was trying:

```auto
[
    {
        "id": "ab3cecbbaca469ea",
        "type": "template",
        "z": "57f319143e2d929c",
        "name": "send empty",
        "field": "template",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "",
        "output": "str",
        "x": 950,
        "y": 540,
        "wires": [
            [
                "79f2285a15c59faf"
            ]
        ]
    },
    {
        "id": "5c9c5b17f4e3af94",
        "type": "template",
        "z": "57f319143e2d929c",
        "name": "send template",
        "field": "template",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "<style> body.nr-dashboard-theme md-list-item._md-button-wrap:nth-child(1) > div:nth-child(1) > div:nth-child(2) { background-color:#32cd32; color: white; } </style>",
        "output": "str",
        "x": 960,
        "y": 600,
        "wires": [
            [
                "79f2285a15c59faf"
            ]
        ]
    },
    {
        "id": "79f2285a15c59faf",
        "type": "ui_template",
        "z": "57f319143e2d929c",
        "group": "7ce31291a1cf860d",
        "name": "",
        "order": 0,
        "width": 0,
        "height": 0,
        "format": "",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": true,
        "templateScope": "global",
        "className": "",
        "x": 1160,
        "y": 560,
        "wires": [
            []
        ]
    },
    {
        "id": "7e4d3b1fa4c2078c",
        "type": "inject",
        "z": "57f319143e2d929c",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 760,
        "y": 600,
        "wires": [
            [
                "5c9c5b17f4e3af94"
            ]
        ]
    },
    {
        "id": "5fdd6d424d5a3bee",
        "type": "inject",
        "z": "57f319143e2d929c",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 750,
        "y": 540,
        "wires": [
            [
                "ab3cecbbaca469ea"
            ]
        ]
    },
    {
        "id": "7ce31291a1cf860d",
        "type": "ui_group",
        "name": "Das ist Gruppe 1",
        "tab": "",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    }
]

```

---

<div class="post-metadata">

### Author: ![nico25](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nico25](https://discourse.nodered.org/u/nico25)
#### Post date: [24 January 2022 06:22 UTC](https://discourse.nodered.org/t/proper-use-of-msg-template-controlling-the-execution-of-template-node/57007/2 "2022-01-24T06:22:42Z")

</div>

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/770e38eb3cade926db8d97ee1a2796f85002cbb5.png)

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [24 January 2022 06:27 UTC](https://discourse.nodered.org/t/proper-use-of-msg-template-controlling-the-execution-of-template-node/57007/3 "2022-01-24T06:27:28Z")

</div>

The red triangle indicates an error in your code.

---

<div class="post-metadata">

### Author: ![nico25](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nico25](https://discourse.nodered.org/u/nico25)
#### Post date: [24 January 2022 06:30 UTC](https://discourse.nodered.org/t/proper-use-of-msg-template-controlling-the-execution-of-template-node/57007/4 "2022-01-24T06:30:43Z")

</div>

It´s an empty template tho.

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/21f30815618cbf99fd39a8d4c52bc716627b7d6a.png)

The red triangle appears as soon as I add it to the head section.  
Is there like a minimum code the template needs to hold?

---

<div class="post-metadata">

### Author: ![nico25](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nico25](https://discourse.nodered.org/u/nico25)
#### Post date: [24 January 2022 08:06 UTC](https://discourse.nodered.org/t/proper-use-of-msg-template-controlling-the-execution-of-template-node/57007/5 "2022-01-24T08:06:34Z")

</div>

Since it worked as long as the template is defined as a "widget in group" I solved it like a noob,copying  
the template in a group of every tab I have 😃

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/95ac7a0c006bb6df5fea70d61ca6268872376d17.png)
