Use config node parameter on function node in subflow


I just noticed that Node-RED 4 allows specifying config nodes as parameters to subflows. It works fine in combination with nodes that expect such a config node, like a dashboard node in the subflow getting the group from a subflow parameter.

Now I wanted to access info from such a config node subflow parameter in a function node within the subflow. Specifically I'd want to get the tab name from the ui_group passed in, but this seems to be a generic issue: When looking at the passed in env-var it looks like it's simply a string. Both when doing env.get("group") in a function node as well as when passing the env var from an inject node to a debug node it simply shows the config node's internal ID only. I can't seem to use things like env.get("group").name to even get the UI group's name.

Is there any way to access the actual node data, not only the config node ID?


Maybe with RED.nodes.node("nodeId")

1 Like


The Function node does not have access to the runtime apis needed to access other nodes and their configuration.

1 Like

That's what I gathered from other topics regarding RED.nodes and similar. So there's no way to use the new system to get info from passed in config nodes for regular flow nodes, it only helps with nodes that actually accept those config nodes in their node configuration?
No way to get e.g. the tab name a passed in ui_group is on?

Why do you want to know something like that?

I'm using the ui_control node on some of my subflows to get notified when a user opens a certain tab to trigger replaying some messages to the frontend so the sstate he is shown is correct. In order to do that only when the correct tab is opened I currently need to type the tab name manually in the subflow configuration. I was hoping with the new changes I could just get the name from the same subflow configuration var where I pass in the ui_group for the UI nodes anyway.

I am sorry, I am not able to understand what you have written, so cannot suggest a better way.

Yeah, I was in a hurry when I wrote that, but wanted to get some info out :slight_smile:

Think this explains it better:

So I have subflows that precede a UI template (and with the new changes the UI template would become part of such subflow ideally). In order to have the UI templates show the latest values whenever they get shown (opening a new dashboard session or even switching between tabs in an active session) I need to listen for UI tab changed events and - if appropriate, i.e. the new tab is the one the UI template is on - send the latest values to the UI template.

Currently my subflow has two inputs related to the UI:
string UITabName - used solely to filter the UI changed event for the correct tab, but has to be entered manually with the exact tab name configured on the dashboard config
ui_group UIGroup - used by the UI template note as the parent group

What I want to have is only the ui_group parameter for the subflow and get the ui_group's tab name from it, so I don't have to pass the manually entered UITabName string that is prone to cause issues.

I hope that was easier to follow than the mess before :slight_smile: