# Random node ids in subflows

**URL:** <https://discourse.nodered.org/t/random-node-ids-in-subflows/61110>\
**Category:** Feature Requests\
**Created:** [11 April 2022 10:19 UTC](https://discourse.nodered.org/t/random-node-ids-in-subflows/61110 "2022-04-11T10:19:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![guidone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/guidone/32/48116_2.png) [@guidone](https://discourse.nodered.org/u/guidone)\
**Post date:** [11 April 2022 10:19 UTC](https://discourse.nodered.org/t/random-node-ids-in-subflows/61110/1 "2022-04-11T10:19:56Z")

</div>

Hi guys,

The context: we're using Node-RED to interact with a conversational API, this means that at some point a custom node calls an endpoint and, when the conversation continues, the API triggers a particular event, at this point the flow should resume from the point it stopped.

The problem is with the code below

```auto
 function createNodeInSubflow(subflowInstanceId, def) {
   let node = clone(def);
   let nid = redUtil.generateId();

```

the id of a node inside a subflow is random, it changes at every restart, which makes impossible to use it as a reference for resuming the flow in the same point it was interrupted calling the API (in case Node-red restarts the original id is lost).

Is there a solution for this problem (having a deterministic reference of what node it's execute in the flow) which doesn't include

- patching the core of Node-RED
- keeping the "status" of the execution inside Node-RED (not a viable solution for us)

Thanks and sorry if this post is a little bit vague

Guido

---

<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:** [11 April 2022 12:39 UTC](https://discourse.nodered.org/t/random-node-ids-in-subflows/61110/2 "2022-04-11T12:39:37Z")

</div>

You can use the `_path` property of the node. That is entirely deterministic between restarts.

---

<div class="post-metadata">

**Author:** ![guidone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/guidone/32/48116_2.png) [@guidone](https://discourse.nodered.org/u/guidone)\
**Post date:** [12 April 2022 14:55 UTC](https://discourse.nodered.org/t/random-node-ids-in-subflows/61110/3 "2022-04-12T14:55:26Z")

</div>

Thanks, this is really helpful, one last question: is there an helper method to get the node instance given the path (or a way to send a msg to a node knowing the path).

Thanks again  
Guido

---

<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:** [12 April 2022 19:51 UTC](https://discourse.nodered.org/t/random-node-ids-in-subflows/61110/4 "2022-04-12T19:51:26Z")

</div>

There is not a helper function for that as it is not something regular nodes have any need to do.

---

<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:** [11 June 2022 19:51 UTC](https://discourse.nodered.org/t/random-node-ids-in-subflows/61110/5 "2022-06-11T19:51:42Z")

</div>

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