# Accessing Flow Information From Custom Node

**URL:** <https://discourse.nodered.org/t/accessing-flow-information-from-custom-node/47858>\
**Category:** Developing Nodes\
**Created:** [30 June 2021 18:06 UTC](https://discourse.nodered.org/t/accessing-flow-information-from-custom-node/47858 "2021-06-30T18:06:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BShashwat](https://avatars.discourse-cdn.com/v4/letter/b/e79b87/32.png) [@BShashwat](https://discourse.nodered.org/u/BShashwat)\
**Post date:** [30 June 2021 18:06 UTC](https://discourse.nodered.org/t/accessing-flow-information-from-custom-node/47858/1 "2021-06-30T18:06:30Z")

</div>

Hi,

I am trying to get the Flow Info within my custom node on input event as follows:

```auto
this.on('input', function (msg, nodeSend, nodeDone) {
            console.info(node.name + " processing start");
            node.start_time = Date.now();
            console.debug("Capturing active flow details - begin");
            const activeWorkspaceId = RED.workspaces.active();
            node.activeflow = RED.nodes.workspace(activeWorkspaceId);
            if (!node.activeflow) {
                // this is probably a subflow
                node.activeSubflow = RED.nodes.subflow(activeWorkspaceId);
                console.debug(node.activeSubflow.info);
            } else {
                console.debug(node.activeflow.info);
            }
});

```

However I am getting error as follows:

`%s - %s 30 Jun 12:07:12 [error] TypeError: Cannot read property 'active' of undefined`

Kindly help with this issue.

Regards

---

<div class="post-metadata">

**Author:** ![lgrkvst](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lgrkvst/32/44321_2.png) [@lgrkvst](https://discourse.nodered.org/u/lgrkvst)\
**Post date:** [3 July 2021 16:07 UTC](https://discourse.nodered.org/t/accessing-flow-information-from-custom-node/47858/2 "2021-07-03T16:07:51Z")

</div>

`RED.workspaces.active` is part of the editor, i.e. you run on the client-side.

`this.on('input')` however takes place on the server-side. Luckily your custom node keeps track of where it belongs. `node._flow` should contain everything you're looking for.

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [3 July 2021 20:45 UTC](https://discourse.nodered.org/t/accessing-flow-information-from-custom-node/47858/3 "2021-07-03T20:45:44Z")

</div>

What problem are you actually trying to solve here?

Nodes shouldn't care where the input comes from or behave differently depending where they are.

---

<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:** [10 August 2021 04:05 UTC](https://discourse.nodered.org/t/accessing-flow-information-from-custom-node/47858/4 "2021-08-10T04:05:49Z")

</div>

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