Iterate over all Nodes in a flow at runtime


I built a Node that lists the IDs of all Nodes with the help of the RED library, but I noticed that the IDs that it returns are not the same IDs as the Nodes have during runtime. Is there any method to get all the Nodes IDs during runtime?

Thank you in advance,
Michel Barnich (Hypertegrity AG.)

Can you post the code you use to iterate over all Nodes?

There are a whole bunch of "fun" things happening with nodes between the flow editor and the run-time, especially around subflows and disabled flows. However, "plain" node IDs don't change. Can you describe what you're trying to do so we can provide some direction on how to achieve it?

I believe the complication arrives with subflows, as there may be multiple instances of a node contained within a subflow, so at run time each one is given a unique id.

Yup, but disabled flows/nodes are also fun 'cause depending on what you iterate over they do or don't exist...

1 Like

Can you explain what you are trying to achieve? That would help us give a more appropriate response.

I have a flow that gathers stats on all nodes in use but it reads the flow JSON file. So it wouldn't deal with un-deployed nodes. There are more dynamic methods via API or function calls but these may have other implications as the others have indicated.