# Subflow - template node - subflow properties

**URL:** <https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658>\
**Category:** Core Development\
**Created:** [26 March 2020 08:01 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658 "2020-03-26T08:01:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![hklages](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hklages/32/23899_2.png) [@hklages](https://discourse.nodered.org/u/hklages)\
**Post date:** [26 March 2020 08:01 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/1 "2020-03-26T08:01:41Z")

</div>

Hi.

How can I access any subflow property in a template - mustache - node?

(My current work around is to use a change node (with $) in combination with a template node.)

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [26 March 2020 08:16 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/2 "2020-03-26T08:16:34Z")

</div>

No I dont think so.  
To my knowledge you can only do it from a function node with `env.get("")` and the way you already do it using a change node.  
Best regards Johannes

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [26 March 2020 10:10 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/3 "2020-03-26T10:10:19Z")

</div>

I just checked with the [source code](https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/nodes/core/function/80-template.js). There is only a special handling for flow and global, so you can access it via `{{flow.name}}` or `{{global.name}}`.  
But none for `env`, though it would be a nice addition.

So copying your env variable to a message property beforehand is the only solution for now.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 March 2020 10:12 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/4 "2020-03-26T10:12:54Z")

</div>

Why are you wanting to access a _subflow property_ outside the subflow?

The idea of a _subflow_ is that it is (as I see it) a _Macro_.

---

<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:** [26 March 2020 10:13 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/5 "2020-03-26T10:13:10Z")

</div>

> [@kuema](#):
>
> But none for `env` , though it would be a nice addition.
> 
> So copying your env variable to a message property beforehand is the only solution for now.

If anyone wanted to propose a PR that added support for `{{env.FOO}}` in the Template node, I'm sure it would be welcome.

---

<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:** [26 March 2020 10:13 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/6 "2020-03-26T10:13:53Z")

</div>

> [@Trying\_to\_learn](#):
>
> Why are you wanting to access a _subflow property_ outside the subflow?

I assume they are wanting to access it from a Template node _inside_ the subflow.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 March 2020 10:16 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/7 "2020-03-26T10:16:49Z")

</div>

Ah. Again I goofed.

Ok, I am not really good with what `env` is compared to `context`, `flow` or `global`.

Would it be pushing the friendship asking?

---

<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:** [26 March 2020 10:21 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/8 "2020-03-26T10:21:42Z")

</div>

> [@Trying\_to\_learn](#):
>
> Would it be pushing the friendship asking?

Not at all - but lets take care not to let this topic stray too off-topic.

`env` is a way to access Environment Variables from within a Node-RED flow - [Using environment variables : Node-RED](https://nodered.org/docs/user-guide/environment-variables)

These are read-only values that can be set outside of Node-RED before it is started. They are useful if you want to run the same set of flows on multiple devices but need each instance to each some configuration value to be device-specific. By setting it via environment variable, you don't need to edit the flows on each device - you set the env-var before running NR.

Building on that, Subflow allow you to define your own env-vars that are defined within the scope of the subflow, or to customise on a per-instance basis.

A key difference between Env Vars and Context is that env vars are read-only and _not_ used for runtime state that may change.

---

<div class="post-metadata">

**Author:** ![hklages](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hklages/32/23899_2.png) [@hklages](https://discourse.nodered.org/u/hklages)\
**Post date:** [26 March 2020 12:01 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/9 "2020-03-26T12:01:56Z")

</div>

Thanks a lot for clarification.

---

<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:** [25 May 2020 12:02 UTC](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/10 "2020-05-25T12:02:00Z")

</div>

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