2022.2

Table Of Contents
Example: AstartupflowneedstouploadanOLConnectresourcetotheOLConnectserver,but
theresourcenameinmsg.payloadlacksthepath.Thepathisstoredinmsg.re-
sourceFolder.Toconstructthefullpathandpassitviamsg.fileName,theflowcanusea
changenode.
l
Addachangenodeandafile uploadnode.
l
Double-clickthechangenodeandcreatearuleto'Set'msg.fileNameto
msg.resourceFolder & payload.ThelatterisaJSONataexpression.
OL Connect Startup flow
AStartupflowisusedinNode-REDprojectsforOLConnecttoinitialize global variablesandto
deploy OL Connect resourcesfortheproject.
Atypicalstartupflowinvolvesthefollowingstandardnodes:inject,read file,JSON,change,split,
anddebug(see"NodesusedinOLConnectflows"onpage185),andoneOLConnectnode:file
upload(see"OLConnectnodes"onpage182).
Triggering a startup flow
TheinjectnodecantriggeraflowinNode-RED.Itcanbesettodothatwhentheflowisdeployedor
whenNode-REDisstarted,byselectingtheInject once afteroptioninitsPropertieswindow.
Inordertovalidatethesetupyoucouldaddadebugnodeandconnectthistotheinjectnode(i.e.join
theoutputportoftheinjectnodewiththeinputportofthedebugnode).Deployingtheflowtriggersthe
injectnode,whichbydefaultaddsatimestamptothepayloadofthemsgobjectwhichispassed
betweennodesinaflow.ThetimestampbecomesvisibleonthedebugtabwhenyouclicktheDebug
iconinthesidebar.
Whentheflowisdeployedforthefirsttime,asuffixappearsaftertheinjectnode'sname,e.g."1".The
suffixindicatesthenumberoftimestheflowhasbeentriggered.
Initializing global variables
VariablesstoredintheglobalcontextofNode-REDarevisibletoallnodes,inallflowsonalltabs.The
valuescouldbesetinachangenodeorscriptedinafunctionnode,forexample(see"Usingvari-
ables"onpage187).
Insteadofhard-codingthevalues,theycouldbereadfromaJSONfile.Theflowwouldneedaread file
nodeandaJSONnodetoreadtheJSONfileandtransformthekeysintheJSONintopropertiesofthe
msg.payload.Next,achangenodecan'Set'globalvariablestothoseproperties.
Tip: OLConnect'scapture foldernodecanreadthenameofthefoldertobemonitoredfor
incomingfilesfromaglobalvariable.
Page 189