2022.1

Table Of Contents
l Via the function node, using JavaScript. The node has access to the msg object as well
as to the different contexts: context (i.e. the node's local context), , flow and global.
The Context sidebar in the editor of Node-RED displays the contents of the context data store
and allows to view the stored variables. The view consists of three sections, one for each
context: node, flow and global.
Variables stored in the global context of Node-RED are visible to all nodes, in all flows, on all
tabs. Through these variables, information is shared between nodes without using the
messages that pass through a flow.
Example
After parsing a JSON string, a startup flow must initialize global variables to the values of
properties of msg.payload.
1. Insert a change node after the JSON node (wire the input port and the output port).
2. Double-click the change node to view its properties.
3. Create a rule for each of the values. For example:
'Set': global.email
To: msg.payload.email
4. Click Done.
5. Add a debug node and connect the change node to the input port of that debug node so
that the result can be viewed in the debug message console.
Setting and moving msg properties
There are various ways to set and move values of properties in the msg object.
l Via the change node. Select 'Set' to set a value; select 'Move' in order to move a value
from one property to another property.
l Via the function node. The value of a property can be set or replaced using JavaScript.
Example
After reading and parsing a manifest.json file, a startup flow needs to move the names of some
OL Connect resources from msg.payload.resources to msg.payload.
Page 207