2022.1

Table Of Contents
OL Connect Startup flow
A Startup flow is used in Node-RED projects for OLConnect to initialize global variables and
to deploy OL Connect resources for the project.
A typical startup flow involves the following standard nodes: inject, read file, JSON, change,
split, and debug (see "OL Connect automation with Node-RED" on page200), and one
OLConnect node: file upload (see "OL Connect nodes" on page200).
Triggering a startup flow
The inject node can trigger a flow in Node-RED. It can be set to do that when the flow is
deployed or when Node-RED is started, by selecting the Inject once after option in its
Properties window.
In order to validate the setup you could add a debug node and connect this to the inject node
(i.e. join the output port of the inject node with the input port of the debug node). Deploying the
flow triggers the inject node, which by default adds a timestamp to the payload of the msg object
which is passed between nodes in a flow. The timestamp becomes visible on the debug tab
when you click the Debug icon in the sidebar.
When the flow is deployed for the first time, a suffix appears after the inject node's name, e.g.
"1". The suffix indicates the number of times the flow has been triggered.
Initializing global variables
Variables stored in the global context of Node-RED are visible to all nodes, in all flows on all
tabs. The values could be set in a change node or scripted in a function node, for example
(see "Node-RED: nodes and common techniques" on page204).
Instead of hard-coding the values, they could be read from a JSON file. The flow would need a
read file node and a JSON node to read the JSON file and transform the keys in the JSON into
properties of the msg.payload. Next, a change node can 'Set' global variables to those
properties.
Page 209