# Subflow environment variables and instance variables

**URL:** <https://discourse.nodered.org/t/subflow-environment-variables-and-instance-variables/51192>\
**Category:** General\
**Created:** [18 September 2021 08:12 UTC](https://discourse.nodered.org/t/subflow-environment-variables-and-instance-variables/51192 "2021-09-18T08:12:57Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [18 September 2021 08:12 UTC](https://discourse.nodered.org/t/subflow-environment-variables-and-instance-variables/51192/1 "2021-09-18T08:12:57Z")

</div>

I am trying to understand the difference between the subflow environment variables and the subflow instance variables and their use cases.

ie. when i doubleclick a subflow, i see a tab "environment variables", when clicking "edit subflow" \> edit properties, there are also environment variables, but they differ as within the subflow they are used for creating the UI inputs.

What are the other differences between the 2 and how should they addressed/ be used, is there a good example available ?

---

<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:** [18 September 2021 09:18 UTC](https://discourse.nodered.org/t/subflow-environment-variables-and-instance-variables/51192/2 "2021-09-18T09:18:17Z")

</div>

I am not sure if this is going to create an _infinite loop_, but here goes.

(I only say this because you participated in it slightly)

[Maybe a useful thread on subflows](https://discourse.nodered.org/t/sample-flow-on-how-to-setup-environment-variable-in-a-sub-flow/25341)

---

<div class="post-metadata">

**Author:** ![molesworth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/molesworth/32/11748_2.png) [@molesworth](https://discourse.nodered.org/u/molesworth)\
**Post date:** [18 September 2021 11:06 UTC](https://discourse.nodered.org/t/subflow-environment-variables-and-instance-variables/51192/3 "2021-09-18T11:06:24Z")

</div>

Do you mean the tab below on the subflow instance?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c76ed07583556424814101d8fc110fdd82e83bf7.png)

I use the "UI Environment Variables" to customise each instance of my subflows, but I've never tried setting additional variables in this tab. However a quick test with a subflow concatenating the UI and "other" env variables seems to work :

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fbde2271bf08e90f3343534420472eb5ec978f75.png)

I'm not sure what the usage of this would be though, as you'd have to document what variables were expected. Setting them in the subflow UI is easier and you can also give them default values.

---

<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:** [17 November 2021 11:06 UTC](https://discourse.nodered.org/t/subflow-environment-variables-and-instance-variables/51192/4 "2021-11-17T11:06:53Z")

</div>

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