How-to
Read a node and all subnodes in Node-RED from the Data Layer
Short answer
A Data Layer address that offers only BROWSE is read in two stages: one Request node set to Method BROWSE returns the child names, a function node turns each into a message carrying the full path, and a second Request node set to Method READ with an empty Path field fetches the values. A group of I/O modules needs one more browse stage, and arbitrarily nested PLC structures need the browse stage fed back into itself until a child list comes back empty.

On this page
- Why does a Data Layer address offer only a browse operation instead of a value?
- How do you turn one browse response into one path per child?
- Why must the Path field stay empty on the read request node?
- How do you read a whole group of I/O modules plus the Master?
- How do you handle PLC structures nested more than two levels deep?
- Why do all data types show as undefined after the function node?
- How do you join the reads into one array without losing the addresses?
- Questions asked
Reading a Data Layer node together with everything below it is a browse-then-read job. Set one Data Layer Request node to Method BROWSE, fan the returned child names out into one message per child with the full address in a path property, and send those messages to a second Data Layer Request node set to Method READ with its Path field left empty. A single branch address such as one I/O module needs exactly those two request nodes; a whole group needs one more browse stage, and PLC structures nested more than two levels deep are covered by feeding the browse output back into the same discovery chain until an address returns no children.
Why does a Data Layer address offer only a browse operation instead of a value? #
Because that address is a branch, not a leaf: the item groups channels below it, exposes no read operation at its own level, and hands out its children only through BROWSE, so the values live one or more levels down. The flow below runs on a ctrlX CORE X3 or X7, or on any ctrlX OS installation with the Node-RED solution and access to the Data Layer.
In the controller's engineering tool, the Data Layer window gives access to the process data of every component registered at the ctrlX OS Data Layer, and each address there shows the operations it supports. The example module XI110116 shows only browse — that display is the tell. BROWSE discovers the children below an address; READ fetches the value of an address that supports reading. A returned child name is not automatically a readable value: it can be another collection that needs browsing first. Leaf status and readability are separate questions, and the operation information in the Data Layer tree answers both, so check it while wiring, not after.
How do you turn one browse response into one path per child? #
Configure a Data Layer Request node with Method BROWSE, confirm the response carries the parent address in msg.topic and the child names in msg.payload, then fan those names out with a function node that emits one message per child.
- Add an inject node so you can fire the flow once while building it.
- Drop a Data Layer Request node, set Method to BROWSE and point its Path field at the branch address.
- Wire a debug node to its output and check the response:
msg.topicholds the parent address andmsg.payloadholds the array of child names — names, not values. - Add a function node with the fan-out code below.
- Connect the function output to a second Data Layer Request node with Method READ and the Path field empty.
for (var i = 0; i < msg.payload.length; i++) {
var data = { path: msg.topic + "/" + msg.payload[i] };
node.send(data);
}
i is the loop counter and data a fresh object whose only property is the string path, built from the parent address, a slash and one child name. Calling node.send inside the loop is what makes this a fan-out: one arriving message leaves as one message per child, each path being the parent address plus slash plus child name. The original example also declared an unused array before the loop; it does nothing and can go.
Prove the stage before going further: a debug node on the function output must show exactly as many messages as the child array is long, no more. While you are in the configuration, give the Data Layer account behind these nodes read-only rights — a discovery flow never needs to write, and read-only rights turn a wiring mistake into an error instead of a changed value.
Why must the Path field stay empty on the read request node? #
Because the node falls back to the path property of each incoming message when its Path field is empty, so every fan-out message selects its own address; a fixed Path would send all of them to the same place. That fallback is the whole trick: one READ node serves every channel the discovery found, and the address travels in the message, not in the node's configuration.
Two things follow. Whatever property carries the address must survive from the function to the read node untouched — do not rename or move it in between. And before aggregating, look at one read response in the debug pane: if the address no longer travels with the value, copy path into msg.topic with a change node ahead of the read, so the join can still key every result on its address.
How do you read a whole group of I/O modules plus the Master? #
Insert a second BROWSE stage: browse the group address first, fan the member names out, browse each member, and only then fan the channels out to the READ node, because the group adds one hierarchy level. The example group holds the modules XI110116, XC811201 and XI342204 plus the Master — three I/O modules and the Master, so four members, not three.
- Browse the group address and compare the returned member list with the modules and the Master you expect.
- Fan the members out with the first function node.
- Feed them into another Data Layer Request node set to BROWSE.
- This stage returns its child array at
msg.payload.value— a different response layout from the first stage, not a second spelling of it — so the second function reads that array:
for (var i = 0; i < msg.payload.value.length; i++) {
var data = { path: msg.topic + "/" + msg.payload.value[i] };
node.send(data);
}
- Send that output to the READ node with the empty Path field.
- Adjust the Batch and Join nodes to the expanded stream.
Sizing one cycle shows why the Join setting follows discovery. The group browse returns 4 members, so the cycle runs 1 group browse plus 4 member browses before any value moves. Take example counts of 8 channels on each module and 4 on the Master — the real numbers come from the debug output at step 4, these only make the arithmetic visible: the READ stage receives 3 × 8 + 4 = 28 messages, and the whole cycle costs 1 + 4 + 28 = 33 Data Layer requests. Count your channels once from that debug output and set the Join to release after exactly that number of reads.
How do you handle PLC structures nested more than two levels deep? #
Feed the second-stage browse output back into the same discovery chain and give the loop an explicit stop: an address whose browse returns an empty child list is a leaf and goes to the READ node instead of back into the browse. Variables and collections sit at different depths, so a fixed two-stage flow stops early — the symptom is that part of the collection appears in the results and the deepest variables never do.
Route the function output through a switch: entries that are collections go back into the browse request node, entries that are variables go to the READ node. Because one browse request node now serves every depth, the path in each message is the only thing separating the levels, which is why the full concatenation of parent, slash and child has to survive every hop. One browse call returning one level of children is also how other address-tree APIs behave; troubleshooting browse folder subnodes with the OPC UA ANSI C SDK hits the same one-level rule on a different stack. When the leaves finally go to a time series, the storage half of that pipeline is covered in recursively browse PLC nodes in Node-RED for InfluxDB.
Why do all data types show as undefined after the function node? #
Because the function builds a fresh object that keeps only the path, so every other property — including the type information your switch tests — is gone before the switch runs. The switch then reads a property that no longer exists on the message, and undefined is what a missing property evaluates to, for every entry alike; that is why the filter cannot separate collections from variables.
Prove it with two debug nodes, one before and one after the function, set to show complete messages: before, the browse response with its per-entry details; after, a single path property. The fix is to copy the property the switch needs into the object you build. Take its exact name from the debug pane of the browse response — never from memory or from a description of another version — carry it alongside path, and route the switch on that carried copy. The fan-out itself stays unchanged.
How do you join the reads into one array without losing the addresses? #
Set the Join node's expected count to the number of read messages the discovery actually produced and key every entry on its full address, because the Join only counts and combines — it cannot recover an address that was dropped upstream. The Batch node controls how messages are grouped or released; the Join combines them into one composite result. Neither node discovers a missing address and neither repairs a failed read, so a short or mixed array is diagnosed at the browse and read boundaries first, before any aggregation setting is touched. For recursion the total is not known until discovery finishes: count the leaves as the switch routes them to READ, hold the running total in the flow's context, and release the Join when the arrived reads match it.
The decision per case:
- One branch address: two request nodes — BROWSE, function, READ — and a Join set to the child count the browse returned.
- A group of modules: three request nodes — group BROWSE, member BROWSE, READ — and a Join set to the discovered channel total.
- Arbitrary depth: browse and READ fed by a switch, termination on an empty child list, and a Join released on the leaf count the run itself produced.
Questions asked
Why does the Data Layer Request node sometimes crash while browsing?
The release notes of the node package node-red-contrib-ctrlx-automation list a possible crash when browsing with bad credentials. Update the package to a current release first, then check the account the nodes use: it must exist on the controller and hold rights on the browsed address. A crash that survives both checks is worth reporting with the flow and the package version.
What happens to the joined array when one read fails?
A failed read does not deliver the message the Join is counting, so the expected count never completes and the cycle stalls or fires late with a gap. Wire the request node's error output separately and decide once, in the flow, whether a failed address is skipped or fails the cycle; either way the released array should mark which addresses never answered.
Is a Data Layer node the same thing as a Node-RED node?
No. A Data Layer node is one addressed item in the controller's data hierarchy, such as a channel, a collection or a module, while a Node-RED node is a processing block in the flow, such as the request or function node. When a diagnosis says a node failed, settle which kind is meant: a Data Layer node fails with an address error, a Node-RED node fails in the editor or the debug sidebar.
Can the joined array go straight into a historian?
Yes, as long as every entry keeps its full address. Same-named channels exist on different modules, so a value stored under its leaf name alone collides; store the complete path with each value, or split the path into tags before writing. Reads also complete out of order between cycles, so key on the address, never on the position in the array.

