2022.2

Table Of Contents
"olsg-invoice-XML.OL-datamapper"
]
}
1. AddaJSONnodeaftertheread filenode.MakesuretheJSONnodeisconnectedtotheoutput
portoftheread filenode.
2. AddadebugnodeandconnecttheJSONnodetotheinputportofthatdebugnodesothatthe
resultcanbeviewedinthedebugmessageconsole,oncetheflowisdeployed.
AftertheJSONfileisparsed,themsgobjectwillhavethefollowingproperties:msg.payload.email,
msg.payload.someApi,msg.payload.workspaceandmsg.payload.resources.
Using variables
Therearevariouswaystosetandgetthevaluesof(globalandother)variables,forexample:
l
Viathechangenode.A'Set'rulecansetthevalueofonevariabletoahard-codedvalueortothe
valueofanothervariable(e.g.'Set'global.emailtomsg.emailobject).
l
Viathefunctionnode,usingJavaScript.Thenodehasaccesstothemsgobjectaswellastothe
differentcontexts:context(i.e.thenode'slocalcontext),,flowandglobal.
TheContextsidebarintheeditorofNode-REDdisplaysthecontentsofthecontextdatastoreand
allowstoviewthestoredvariables.Theviewconsistsofthreesections,oneforeachcontext:node,
flowandglobal.
Variablesstoredintheglobal contextofNode-REDarevisibletoallnodes,inallflows,onalltabs.
Throughthesevariables,informationissharedbetweennodeswithoutusingthemessagesthatpass
throughaflow.
Example
AfterparsingaJSONstring,astartupflowmustinitializeglobalvariablestothevaluesofpropertiesof
msg.payload.
1. InsertachangenodeaftertheJSONnode(wiretheinputportandtheoutputport).
2. Double-clickthechangenodetoviewitsproperties.
3. Createaruleforeachofthevalues.Forexample:
'Set':global.email
To:msg.payload.email
4. ClickDone.
Page 187