# How to disable a tab at startup

**URL:** <https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037>\
**Category:** General\
**Created:** [19 November 2018 12:24 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037 "2018-11-19T12:24:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jc-nr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jc-nr/32/49790_2.png) [@jc-nr](https://discourse.nodered.org/u/jc-nr)\
**Post date:** [19 November 2018 12:24 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/1 "2018-11-19T12:24:34Z")

</div>

Is it possible to enable/disable a tab at startup, with an environment variable ?  
Something like this :

```auto
{
  "id" : "5f773146.6bf5",
  "type" : "tab",
  "label" : "Test",
  "disabled": "$env('DISABLE_TESTS')",
  "info" : ""
}

```

---

<div class="post-metadata">

**Author:** ![JayGhb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jayghb/32/5550_2.png) [@JayGhb](https://discourse.nodered.org/u/JayGhb)\
**Post date:** [19 November 2018 14:04 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/2 "2018-11-19T14:04:28Z")

</div>

> [@I can hide the "tab name" in the dashboard?](https://discourse.nodered.org/t/i-can-hide-the-tab-name-in-the-dashboard/1184):
>
> we can to hide the "tab name" located at the left side of the dashboard? Like the following image. [Sans%20titre] and keep the content that I can access it with the "ui-control" Thank you .

Judging from this discussion I believe it is not currently possible to hide or disable specific tabs,  
at least not in an easy way. Read through it though, it might help.  
Jason.

---

<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:** [19 November 2018 14:12 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/3 "2018-11-19T14:12:24Z")

</div>

@JayGhb that discussion is about dashboard tabs. The question here is about tabs, aka flows, in the editor

@jc-nr if it works, the syntax would be:

```auto
"disabled": "$(DISABLE_TESTS)"

```

which is how you can set any node property by environment variables.

However...

1. I cannot remember if the environment variable handling is applied to tab nodes.
2. If it does, I can't remember if the code will handle the value being a string rather than a Boolean

I'm out of the office this week so cannot look at the code on my laptop to give a more definitive answer.

So try it and see.... but based in the above, you may find it doesn't work.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [19 November 2018 15:46 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/4 "2018-11-19T15:46:27Z")

</div>

> [@jc-nr](#):
>
> Is it possible to enable/disable a tab at startup, with an environment variable ?

Node-Red allows to access environment variables, within a flow, in a couple of ways. Check this link out:

> **[Version 0.19 released](https://nodered.org/blog/2018/08/14/version-0-19-released)**
>
> Find out more on the blog

Perhaps you could modify this flow from the library to achieve your purpose

[https://flows.nodered.org/flow/7c67709fecce1ad5992b695028e57646](https://flows.nodered.org/flow/7c67709fecce1ad5992b695028e57646)

The idea of such flow is to use the value of an environment variable, for instance, COMPUTERNAME to gate (block or unblock) the message flow.

 ![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7827bb2d8dfad0f649e022950830a5e1cf4243b6.png)

Testing

```auto
[{"id":"e310b11c.dcfc4","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"7a43bf4b.7d43b","type":"switch","z":"e310b11c.dcfc4","name":"Is this my computer ?","property":"$env(\"COMPUTERNAME\")","propertyType":"jsonata","rules":[{"t":"eq","v":"DESKTOP-PTRIO67","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":340,"y":240,"wires":[["763f0cbb.0a6cb4","f5a1884f.99a468"]]},{"id":"8b7a95a9.3d4598","type":"inject","z":"e310b11c.dcfc4","name":"my computer","topic":"","payload":"DESKTOP-PTRIO67","payloadType":"str","repeat":"6","crontab":"","once":true,"onceDelay":"","x":140,"y":240,"wires":[["7a43bf4b.7d43b"]]},{"id":"763f0cbb.0a6cb4","type":"function","z":"e310b11c.dcfc4","name":"Generate Random Data","func":"msg.payload = Math.round(Math.random()*100);\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":240,"wires":[["4db19f43.a8586"]]},{"id":"4db19f43.a8586","type":"debug","z":"e310b11c.dcfc4","name":"","active":true,"console":"false","complete":"false","x":790,"y":240,"wires":[]},{"id":"f15a9564.82bf78","type":"comment","z":"e310b11c.dcfc4","name":"Enable / Disable a Flow","info":"https://flows.nodered.org/flow/7c67709fecce1ad5992b695028e57646\n\n","x":160,"y":100,"wires":[]},{"id":"8be630f7.ed4fa","type":"change","z":"e310b11c.dcfc4","name":"Enviromental variables","rules":[{"t":"set","p":"a","pt":"msg","to":"COMPUTERNAME","tot":"env"},{"t":"set","p":"b","pt":"msg","to":"$env(\"COMPUTERNAME\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":420,"wires":[["3e88fb01.400b54"]]},{"id":"ff05f967.993978","type":"inject","z":"e310b11c.dcfc4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":420,"wires":[["8be630f7.ed4fa"]]},{"id":"3e88fb01.400b54","type":"debug","z":"e310b11c.dcfc4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":580,"y":420,"wires":[]},{"id":"f5a1884f.99a468","type":"debug","z":"e310b11c.dcfc4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":530,"y":180,"wires":[]},{"id":"7f4cfa9f.82f8a4","type":"comment","z":"e310b11c.dcfc4","name":"Example: using environment variables in node change","info":"","x":260,"y":380,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![jc-nr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jc-nr/32/49790_2.png) [@jc-nr](https://discourse.nodered.org/u/jc-nr)\
**Post date:** [19 November 2018 16:50 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/5 "2018-11-19T16:50:17Z")

</div>

I will give it a try, thanks!

---

<div class="post-metadata">

**Author:** ![jc-nr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jc-nr/32/49790_2.png) [@jc-nr](https://discourse.nodered.org/u/jc-nr)\
**Post date:** [20 November 2018 12:30 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/6 "2018-11-20T12:30:56Z")

</div>

@Andrei I'm using this approach yet. But it's not suitable for all use case (for example : the "e-mail in" builtin node).  
I thought I could take advantage of the new property "disabled" of tabs.

@knolleary I tried the syntax, but you were right : the string is evaluated as a true expression and the tab is always disabled.

Maybe in another version...

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [20 November 2018 12:38 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/7 "2018-11-20T12:38:55Z")

</div>

@jc-nr, I suspected that but anyway the flow could be of use for someone else. In general how do you modify a property of the flow.json file (like disabled for instance) ? Do you do it programatically, using Node-RED API or at run time using a regular flow ? Let´s say you wanted to change another property, like label. How would you do that ? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![jc-nr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jc-nr/32/49790_2.png) [@jc-nr](https://discourse.nodered.org/u/jc-nr)\
**Post date:** [22 November 2018 10:44 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/8 "2018-11-22T10:44:06Z")

</div>

@Andrei You mean at startup ?

---

<div class="post-metadata">

**Author:** ![scotie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scotie/32/5981_2.png) [@scotie](https://discourse.nodered.org/u/scotie)\
**Post date:** [24 October 2019 15:22 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/9 "2019-10-24T15:22:44Z")

</div>

> [@jc-nr](#):
>
> @knolleary I tried the syntax, but you were right : the string is evaluated as a true expression and the tab is always disabled.

This is still the case in `1.0.0`

@knolleary, is there another way to do this?  
I'm trying to disable / enable a tab by setting the enviroment variable in a `balena.io` deployed device.

Thanks

---

<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:** [24 October 2019 16:07 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/10 "2019-10-24T16:07:59Z")

</div>

You could add something in your settings.js file that parses the env var to a boolean type:

```auto
if (process.env.MY_ENV_VAR === "false") {
   process.env.MY_ENV_VAR = false;
}

```

---

<div class="post-metadata">

**Author:** ![scotie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scotie/32/5981_2.png) [@scotie](https://discourse.nodered.org/u/scotie)\
**Post date:** [24 October 2019 19:35 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/11 "2019-10-24T19:35:34Z")

</div>

Hi Nick,  
Do you mean inside `module.exports = {}` ?

---

<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:** [24 October 2019 19:47 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/12 "2019-10-24T19:47:18Z")

</div>

No, it wouldn't be valid JavaScript inside the module.exports block. Put it at the top of the file.

---

<div class="post-metadata">

**Author:** ![scotie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scotie/32/5981_2.png) [@scotie](https://discourse.nodered.org/u/scotie)\
**Post date:** [24 October 2019 19:56 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/13 "2019-10-24T19:56:52Z")

</div>

It's still evaluated as `"false"`

Any other way around it?

---

<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:** [24 October 2019 20:06 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/14 "2019-10-24T20:06:17Z")

</div>

It appears that `process.env` coerces anything you give it to a String.

The only other workaround would be to dynamically edit the flow file before NR starts to set the property as you want it.

---

<div class="post-metadata">

**Author:** ![eastling](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eastling/32/39127_2.png) [@eastling](https://discourse.nodered.org/u/eastling)\
**Post date:** [18 October 2021 14:39 UTC](https://discourse.nodered.org/t/how-to-disable-a-tab-at-startup/5037/15 "2021-10-18T14:39:24Z")

</div>

@scotie - How did you end up solving this?  
In my case I want to disable some configuration nodes based on environment variables.
