# Getting current tab(flow) id from sidebar

**URL:** <https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934>\
**Category:** General\
**Created:** [16 November 2018 13:32 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934 "2018-11-16T13:32:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![malinthasa](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@malinthasa](https://discourse.nodered.org/u/malinthasa)\
**Post date:** [16 November 2018 13:32 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934/1 "2018-11-16T13:32:55Z")

</div>

Hi,

Can I get the id of the opened tab (which is already deployed) from a sidebar? I am getting the flow description using flows/ endpoint but I want current flow id to filter the response from the flows/ API call. I thought using editor [events](https://github.com/node-red/node-red/wiki/Design:-Editor-Events) and tried `workspace: change`. But it provides only the older tab id but not the current tab id. Is there any way to get the current tab id from my sidebar html?

Regards,  
Malintha

---

<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:** [16 November 2018 14:11 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934/2 "2018-11-16T14:11:55Z")

</div>

Hi,

the payload of the `workspace:change` event has two properties - the old workspace you were on and the new workspace you've switched to:

```auto
{
    old: oldWorkspaceId,
    workspace: newWorkspaceId
}

```

But there's no need to track that yourself. You can get the id of the current workspace tab by calling:

```auto
  var activeWorkspaceId = RED.workspaces.active();

```

Once you have that id, it might be a subflow tab or a flow tab. To check which it is, you can do:

```auto
  var activeWorkspaceId = RED.workspaces.active();
  var flow = RED.nodes.workspace(activeWorkspaceId);
  if (!flow) {
    // this is probably a subflow
    flow = RED.nodes.subflow(activeWorkspaceId);
  }

```

Once you have that `flow` object you have access to all its properties - such as `flow.info` for its description. There's no need to use the `/flow` api to get this information.

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [18 November 2019 19:17 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934/3 "2019-11-18T19:17:56Z")

</div>

Ok, one later later...  
i would like to get the name of the current flow.  
so with the above i tried this below

```auto
var activeWorkspaceId = RED.workspaces.active();
msg.payload = activeWorkspaceId;
return msg;

```

but that gives the error

```auto
"TypeError: Cannot read property 'active' of undefined"

```

maybe i understand the usage wrong?

---

<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:** [18 November 2019 19:33 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934/4 "2019-11-18T19:33:47Z")

</div>

Where are you trying to do that? In a custom node or a Function node? If the latter, it doesn't have access to these APIs.

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [18 November 2019 19:59 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934/5 "2019-11-18T19:59:55Z")

</div>

in the function node.  
Is there another way to get it?

Thanks!

---

<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:** [18 November 2019 22:33 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934/6 "2019-11-18T22:33:17Z")

</div>

Nodes are supposed to be black boxes so have no concept of where they are.

---

<div class="post-metadata">

**Author:** ![sdrshnptl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sdrshnptl/32/40446_2.png) [@sdrshnptl](https://discourse.nodered.org/u/sdrshnptl)\
**Post date:** [19 November 2021 09:13 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934/7 "2021-11-19T09:13:56Z")

</div>

> [@RogierQ](#):
>
> `RED.workspaces.active`

Did you fand solution for this?

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [22 November 2021 10:20 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934/8 "2021-11-22T10:20:04Z")

</div>

no sorry. I did not find a solution that worked

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 November 2021 11:34 UTC](https://discourse.nodered.org/t/getting-current-tab-flow-id-from-sidebar/4934/9 "2021-11-22T11:34:22Z")

</div>


