# Subflow disappointment

**URL:** <https://discourse.nodered.org/t/subflow-disappointment/15323>\
**Category:** General\
**Created:** [9 September 2019 15:03 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323 "2019-09-09T15:03:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [9 September 2019 15:03 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323/1 "2019-09-09T15:03:44Z")

</div>

I just finished developing a subflow which controls my TFT display, its self contained using mqtt to send info to the display and receive info like when the screen is pressed etc, the subflow has just 3 outputs to interact with the main flow all the other necessary variables in the subflow are from flow.set(.parent,bla bla flow.get('.parent,bla.bla, it works great, but one of the reasons I transferred the code into a subflow was the thought that I could disable the subflow just like a normal flow, but shock theirs no disable switch ,  
Is there any other way I can disable this subflow ?

---

<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:** [9 September 2019 15:13 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323/2 "2019-09-09T15:13:59Z")

</div>

> [@Dave](#):
>
> Is there any other way I can disable this subflow ?

You will be able to disable them in 1.0.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 September 2019 15:14 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323/3 "2019-09-09T15:14:56Z")

</div>

The latest 1.0 beta allows you to enable/disable individual nodes (and subflows).  
Prior to that you could only disable tabs (and yes subflow "tabs" didn't count as real flow tabs so can't be disabled. But seeing as it's a subflow - could you not just unwire it's one input and it won't be triggered...

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [9 September 2019 15:48 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323/4 "2019-09-09T15:48:06Z")

</div>

I am on node-red 0.20.7 so it looks like I need take a look at 1.0.3

(the subflow node doesn't have any input its triggered from the TFT screen via mqtt)

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [9 September 2019 15:50 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323/5 "2019-09-09T15:50:20Z")

</div>

Most solutions (pre-1.0) include a `switch` node right before the subflow -- the switch test expression can refer to a flow or global variable (e.g. isTFTenabled flag) and drop any incoming messages unless that variable is set.

Then you can build other flows to set that flag -- like setting it to true/false based on the position of a dashboard switch, or the time of day, or toggled by an `inject` node in the editor...

> [@Dave](#):
>
> (the subflow node doesn't have any input its triggered from the TFT screen via mqtt)

Sorry, missed that little detail... In that case, your go/nogo switch will have to be included inside the subflow -- which is unfortunate, since you'll have to use global context.

---

<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:** [10 September 2019 03:43 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323/6 "2019-09-10T03:43:51Z")

</div>

I'll play _Devil's advocate_ here.

Suggestion @Dave.

Although you are trying to avoid it, have an input to the sub-flow as @shrickus was hoping.  
But use that input as suggested.

Then **in the subflow** use that input _signal_ to control of the sub-flow is used or not/accepts inputs.

That is a way _around_ the problem as it stands.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [10 September 2019 03:49 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323/7 "2019-09-10T03:49:52Z")

</div>

> [@dceejay](#):
>
> The latest 1.0 beta allows you to enable/disable individual nodes (and subflows).

I have seen this in the "edit" dialog, that's good. Is there an api as well so I can do it from code?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 September 2019 06:10 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323/8 "2019-09-10T06:10:08Z")

</div>

No, the code solution is to create gate like nodes as above

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [10 September 2019 10:23 UTC](https://discourse.nodered.org/t/subflow-disappointment/15323/9 "2019-09-10T10:23:58Z")

</div>

Thanks for all the suggestions, the reason I wanted to disable the subflow was to include the same subflow on a different pi and have that one send the info to the TFT, currently just for testing, I don't really want extra switches and stuff.

I found a simple solution for that until I upgrade to nr 1.0. I just exported the subflow into the Library then deleted the subflow, same on the second pi, then I just import the subflow on which ever pi I want TFT to work with. sorted.
