# Template-node error

**URL:** <https://discourse.nodered.org/t/template-node-error/67830>\
**Category:** General\
**Created:** [17 September 2022 04:04 UTC](https://discourse.nodered.org/t/template-node-error/67830 "2022-09-17T04:04:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 04:04 UTC](https://discourse.nodered.org/t/template-node-error/67830/1 "2022-09-17T04:04:02Z")

</div>

I am trying to pass the content of a global variable to an HTTP-in node  
In my template node I have the following:

```auto
{
Learning status: {{global.get("LearningStatus")}}
}

```

but it is giving error when the request is sent to the HTTP-in node.  
"Invalid property expression: unexpected " at position 4"

How can I pass the value of the global variable to the template node in the correct way?  
Thanks for helping.

---

<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:** [17 September 2022 05:12 UTC](https://discourse.nodered.org/t/template-node-error/67830/2 "2022-09-17T05:12:29Z")

</div>

Properties can not contain spaces, not sure if this is the source of the error but that should be solved at least.

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 05:27 UTC](https://discourse.nodered.org/t/template-node-error/67830/3 "2022-09-17T05:27:47Z")

</div>

Thanks for highlighting the typo. I corrected it but the problem is still the same.  
it reads like this now:

```auto
{
Learning_status:{{global.get("LearningStatus")}}
}

```

Invalid property expression: unexpected " at position 4

---

<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:** [17 September 2022 08:04 UTC](https://discourse.nodered.org/t/template-node-error/67830/4 "2022-09-17T08:04:46Z")

</div>

In a template node it would be

```auto
{
Learning_status: {{global.LearningStatus}}
}

```

and if you wanted valid json  
it would be

```auto
{
"Learning_status": "{{global.LearningStatus}}"
}

```

Depending thee value of global.learningStatus.

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 13:47 UTC](https://discourse.nodered.org/t/template-node-error/67830/5 "2022-09-17T13:47:11Z")

</div>

Thank you.  
I don't get errors anymore but still I cannot get the value of the global.LearningStatus.  
I get **"Learning\_status": "[object Object]"** rather than the real value which is "Process stopped" or "Process started".  
I tested the value of the global.LearningStatus and it is correct. I tested both the code you suggested but same result. Not sure about what this issue is now.

---

<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:** [17 September 2022 13:48 UTC](https://discourse.nodered.org/t/template-node-error/67830/6 "2022-09-17T13:48:42Z")

</div>

Then global.learning\_status is an object. Show us the global value in the sidebar.

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 13:50 UTC](https://discourse.nodered.org/t/template-node-error/67830/7 "2022-09-17T13:50:33Z")

</div>

![Screenshot 2022-09-17 at 15.50.00](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/7/175798fbba3677ed657c962f4eec466baed48450.png)

---

<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:** [17 September 2022 13:51 UTC](https://discourse.nodered.org/t/template-node-error/67830/8 "2022-09-17T13:51:45Z")

</div>

That is not the context sidebar that is the debug sidebar. We need to see what the global is set at.

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 13:53 UTC](https://discourse.nodered.org/t/template-node-error/67830/9 "2022-09-17T13:53:10Z")

</div>

```auto
[{"id":"ee1921195e1f3b6c","type":"status","z":"c77ba1683e345234","name":"ExecStatus","scope":["c4ff59a7c876123f"],"x":1050,"y":720,"wires":[["d78095b461723415"]]},{"id":"d78095b461723415","type":"function","z":"c77ba1683e345234","name":"CheckStatus","func":"\nvar test = msg.status.text;\n\nif (test.includes('pid:')) { \n msg.payload=\"Process running\"\n}\n\nelse if (test.includes('kill')) { \n msg.payload=\"Process stopped\"\n}\n\nelse {\n msg.payload=\"Unknow process status\"\n}\nmsg.topic=\"Learnig status\";\nmsg.payload={\"Status\":msg.payload, \"Topic\":msg.topic};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1250,"y":720,"wires":[["ab3735fbdb4de2c8"]]},{"id":"ede1db84ccbe2c51","type":"http in","z":"c77ba1683e345234","name":"Input from KIosk","url":"/api/learningstatus","method":"get","upload":false,"swaggerDoc":"","x":1060,"y":800,"wires":[["4270a9372c1fbbe5"]]},{"id":"4135fe289f5c7d33","type":"http response","z":"c77ba1683e345234","name":"","statusCode":"200","headers":{},"x":1420,"y":800,"wires":[]},{"id":"4270a9372c1fbbe5","type":"template","z":"c77ba1683e345234","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\"Learning_status\": \"{{global.LearningStatus}}\"\n","output":"str","x":1240,"y":800,"wires":[["4135fe289f5c7d33"]]},{"id":"ab3735fbdb4de2c8","type":"change","z":"c77ba1683e345234","name":"","rules":[{"t":"set","p":"LearningStatus","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1450,"y":720,"wires":[["bfe334ed56797848"]]},{"id":"bfe334ed56797848","type":"debug","z":"c77ba1683e345234","name":"Var from setting","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1680,"y":720,"wires":[]}]

```

 ![Screenshot 2022-09-17 at 15.52.37](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/555d588374519ae1cfeb5cb0aa10ca63a88ff979.png)

---

<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:** [17 September 2022 13:54 UTC](https://discourse.nodered.org/t/template-node-error/67830/10 "2022-09-17T13:54:57Z")

</div>

Again that is a change node, we need to see the context sidebar . at top of the sidebar select the icon that looks like 3 coins and then refresh global and show us the result.

[edit]  
I suspect it is `global.learningStatus.Status`.  
in your change node you should of set  
`global.learningStatus`  
to  
`msg.payload.Status`.  
If you wanted the value at `global.learningStatus`

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 13:58 UTC](https://discourse.nodered.org/t/template-node-error/67830/11 "2022-09-17T13:58:06Z")

</div>

Sorry for that... 🫤. I think you asking for this :

 ![Screenshot 2022-09-17 at 15.56.58](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1fee382c409150d062369540fdcee1e785336e.png)

---

<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:** [17 September 2022 13:59 UTC](https://discourse.nodered.org/t/template-node-error/67830/12 "2022-09-17T13:59:45Z")

</div>

see my edited post above.

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 14:05 UTC](https://discourse.nodered.org/t/template-node-error/67830/13 "2022-09-17T14:05:57Z")

</div>

In the template node now I have

```auto
"Learning_status": "{{global.LearningStatus.status}}"

```

In the change node I have set the variable to msg.payload.status  
If I send the request I get: "Learning\_status": ""  
The value of the variable is not there yet. Sorry for bothering you with this

---

<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:** [17 September 2022 14:06 UTC](https://discourse.nodered.org/t/template-node-error/67830/14 "2022-09-17T14:06:47Z")

</div>

Capital S for Status in `msg.payload.Status`, and use `global.learningStatus`

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 14:13 UTC](https://discourse.nodered.org/t/template-node-error/67830/15 "2022-09-17T14:13:13Z")

</div>

![Screenshot 2022-09-17 at 16.11.41](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3f3e1026f880eede41a78a504ced273d00f01b44.png)

 ![Screenshot 2022-09-17 at 16.11.19](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/7/0702fee7bb9bcbbf5cbd60e4b2b0d3c7deb6d460.png)

Not my day! I still get

 ![Screenshot 2022-09-17 at 16.12.55](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/7/d7f77493dbaf61f9da1c74b3df56973b6a820f10.png)

---

<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:** [17 September 2022 14:14 UTC](https://discourse.nodered.org/t/template-node-error/67830/16 "2022-09-17T14:14:33Z")

</div>

what is in template and what is sidebar context showing? don't forget to refresh global context in sidebar.

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 14:16 UTC](https://discourse.nodered.org/t/template-node-error/67830/17 "2022-09-17T14:16:24Z")

</div>

I updated above with the template.

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 14:18 UTC](https://discourse.nodered.org/t/template-node-error/67830/19 "2022-09-17T14:18:31Z")

</div>

In the sidebar context there is always a value, Process stopped or process started

---

<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:** [17 September 2022 14:19 UTC](https://discourse.nodered.org/t/template-node-error/67830/20 "2022-09-17T14:19:06Z")

</div>

Do yo think you could show us, as we can not assume.

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [17 September 2022 14:19 UTC](https://discourse.nodered.org/t/template-node-error/67830/21 "2022-09-17T14:19:58Z")

</div>

sure

 ![Screenshot 2022-09-17 at 16.19.37](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/4/a429cd7e15a28625ec4937edd95e7b9b814c4052.png)

```auto
[{"id":"ee1921195e1f3b6c","type":"status","z":"c77ba1683e345234","name":"ExecStatus","scope":["c4ff59a7c876123f"],"x":1050,"y":720,"wires":[["d78095b461723415"]]},{"id":"d78095b461723415","type":"function","z":"c77ba1683e345234","name":"CheckStatus","func":"\nvar test = msg.status.text;\n\nif (test.includes('pid:')) { \n msg.payload=\"Process running\"\n}\n\nelse if (test.includes('kill')) { \n msg.payload=\"Process stopped\"\n}\n\nelse {\n msg.payload=\"Unknow process status\"\n}\nmsg.topic=\"Learnig status\";\nmsg.payload={\"Status\":msg.payload, \"Topic\":msg.topic};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1250,"y":720,"wires":[["ab3735fbdb4de2c8"]]},{"id":"ede1db84ccbe2c51","type":"http in","z":"c77ba1683e345234","name":"Input from KIosk","url":"/api/learningstatus","method":"get","upload":false,"swaggerDoc":"","x":1060,"y":760,"wires":[["4270a9372c1fbbe5"]]},{"id":"4135fe289f5c7d33","type":"http response","z":"c77ba1683e345234","name":"","statusCode":"200","headers":{},"x":1420,"y":760,"wires":[]},{"id":"4270a9372c1fbbe5","type":"template","z":"c77ba1683e345234","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\"Learning_status\": \"{{global.learningStatus}}\"\n","output":"str","x":1240,"y":760,"wires":[["4135fe289f5c7d33"]]},{"id":"ab3735fbdb4de2c8","type":"change","z":"c77ba1683e345234","name":"","rules":[{"t":"set","p":"LearningStatus","pt":"global","to":"payload.Status","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1450,"y":720,"wires":[["bfe334ed56797848"]]},{"id":"bfe334ed56797848","type":"debug","z":"c77ba1683e345234","name":"Var from setting","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1680,"y":720,"wires":[]}]

```

[Next page](https://discourse.nodered.org/t/template-node-error/67830.md?page=2)
