# Node id from within a subflow

**URL:** <https://discourse.nodered.org/t/node-id-from-within-a-subflow/34658>\
**Category:** Feature Requests\
**Created:** [22 October 2020 07:04 UTC](https://discourse.nodered.org/t/node-id-from-within-a-subflow/34658 "2020-10-22T07:04:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelblight](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelblight/32/445_2.png) [@michaelblight](https://discourse.nodered.org/u/michaelblight)\
**Post date:** [22 October 2020 07:04 UTC](https://discourse.nodered.org/t/node-id-from-within-a-subflow/34658/1 "2020-10-22T07:04:37Z")

</div>

The debug window shows the id of the `debug` node that produced the output, except when it's inside a subflow. In this case it shows the id of the subflow instance (the calling node).

Within a `function` node, `node.id` returns the id of the node. If the function is inside a subflow, it would be useful to be able to return the id of the calling node. Along the lines of `node.parent.id`, where `parent` was only non-null for subflows. Logically it would also extend to `node.parent.parent.id` for subflows within subflows. Note that this is different to using the `$parent` context, which is at the flow level.

My use case is for logging within a subflow that is used in multiple flows, to know which node called the subflow. I have many flows and each calls the subflow many times, so using `$parent.name` doesn't give me enough information and `$parent.id` doesn't exist (and would logically be the flow id anyway).

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [22 October 2020 20:39 UTC](https://discourse.nodered.org/t/node-id-from-within-a-subflow/34658/2 "2020-10-22T20:39:51Z")

</div>

Although it adds boilerplate, you could add the needed source information to the msg before entering the subflow as a workaround. Or alternatively add a field to the subflow instance containing the source. Both of these workarounds would need manual maintenance so not ideal of course.

---

<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:** [21 December 2020 20:40 UTC](https://discourse.nodered.org/t/node-id-from-within-a-subflow/34658/3 "2020-12-21T20:40:00Z")

</div>

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