# Subflows & environment variables?

**URL:** <https://discourse.nodered.org/t/subflows-environment-variables/10782>\
**Category:** General\
**Created:** [3 May 2019 15:01 UTC](https://discourse.nodered.org/t/subflows-environment-variables/10782 "2019-05-03T15:01:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JesseWebDotCom](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@JesseWebDotCom](https://discourse.nodered.org/u/JesseWebDotCom)\
**Post date:** [3 May 2019 15:01 UTC](https://discourse.nodered.org/t/subflows-environment-variables/10782/1 "2019-05-03T15:01:55Z")

</div>

I'm using subflows and their instance environment variables. How can I pass or override the instance environment variable values from another node? It looks like I could set them to reference other environment variables but how do I externally set those variables?

 ![subflow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/6ad7fbf580d87e43bc4159937264503eae7ab830.png)

---

<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:** [3 May 2019 15:05 UTC](https://discourse.nodered.org/t/subflows-environment-variables/10782/2 "2019-05-03T15:05:46Z")

</div>

Env Vars cannot be dynamically changed. They are read-only when the flow starts.

The `process` object is not available in the Function node.

---

<div class="post-metadata">

**Author:** ![JesseWebDotCom](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@JesseWebDotCom](https://discourse.nodered.org/u/JesseWebDotCom)\
**Post date:** [3 May 2019 15:19 UTC](https://discourse.nodered.org/t/subflows-environment-variables/10782/3 "2019-05-03T15:19:24Z")

</div>

How do you recommend I proceed? I am basically trying to cleanup flows by putting repeatable patterns into subflows. But those subflows require values to operate correctly. Sometimes I can hard code those values. Other times I need to calculate those values (ex. with a function node).

I could embed them in an arbitrary portion of the message passed to the subflow (ex. msg.subflow). It just seems like subflow environment variables were the way to go.

Thanks in advance

---

<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:** [3 May 2019 15:36 UTC](https://discourse.nodered.org/t/subflows-environment-variables/10782/4 "2019-05-03T15:36:08Z")

</div>

It is up to individual nodes as to whether a particular property can be set by the messages it receives. So how you proceed will depend on the specific details of what you want to do and what nodes you want to configure in this way.

Env Vars were never about dynamically changing the configuration after a flow has been deployed. There is no mechanism to change a node's configuration without a deploy to ensure the change takes effect.

---

<div class="post-metadata">

**Author:** ![JesseWebDotCom](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@JesseWebDotCom](https://discourse.nodered.org/u/JesseWebDotCom)\
**Post date:** [3 May 2019 15:39 UTC](https://discourse.nodered.org/t/subflows-environment-variables/10782/5 "2019-05-03T15:39:04Z")

</div>

Thanks for the quick response. Seems like my needs correspond to this thread:

> [@Shared subflow context](https://discourse.nodered.org/t/shared-subflow-context/3596/9):
>
> I think I was not clear at first. I don't ask for a flow and a subflow to share the flow context. I don't ask for a subflow to share his flow context with other subflows. It would be a new context called... static\_subflow. It's like static variables of a class X. If you instaciate multiple time the class X, they will all have their own private properties, but they also share static variables. I'd like to see to same for subflows. All instances of a subflow would have their own flow context,…

I guess I'll just put data I need to transfer into subflows under msg.subflow until a common mechanism or standard arises. Thanks again
