I am trying to get the current flow name when a message passes through. I figured out how to get the flow id (from config.z) but could not find the flow name anywhere at runtime. The nodered docs mention that there is an api method to get a flow (https://nodered.org/docs/api/runtime/api#getFlow) but this does not work either- I get an error when I try RED.nodes.getFlow(id) Any pointers will be greatly appreciated.
0
votes
That admin API method is meant to be an external http endpoint, not a way for javascript in a function node to get information. Are you trying to get the flow name from within a function node, or in a custom node's runtime code?
- SteveR
Thanks for your reply Steve. I am trying to get the flow name from inside a custom node's runtime code.
- umasudhan
You need to update your question to let us know what you are trying to achieve. Your node should not need to know anything about it's flow.
- Julian Knight
I am writing a custom node which will add the current flow name to the msg going through it. This will be used by other function nodes which will read the msg property. Please tell me if you want me to clarify this further
- umasudhan
The question is fairly clear, and so is the fact that any node's runtime code does not have access to the current flow's name, only its id (by design). Personally, I don't understand why that could not be made available -- but you will need to start that discussion on the mailing list in order to help the developers understand the need. Generally, any ideas that help the community and fit the design model are quickly integrated into node-red.
- SteveR
1 Answers
0
votes
This is not an approach that is generally supported by flow-based programming. No node should know anything much about the previous nodes in the flow other than what is set in the msg that is passed.
To achieve what you want, simply add a msg.topic with an identifier. Or indeed, some other identifying property. You can do this using a number of different nodes.
If you need more information, you will need to explain why you want a flow identifier.