2022.2

Table Of Contents
Tip: Doyoufindyourselfcopy-pastingthesamefunctionintoeverynewscript?Youcanavoid
thisbydefiningyourfunctioninaControlScript.ControlScriptsareexecutedfirst,sothefunction
willthenbeavailableinallStandardScriptsandPostPaginationScripts.
Handlebars Helpers
AHandlebarsHelper-afunctionthatcanbeusedinexpressions-isalsodefinedinaControlScript.
HelperscanbemadewiththeHandlebarsTextHelperwizard(see"UsingtheHelperWizard"on
page310)oryoucanwritethemyourself(see"CreatingcustomHelpers"onpage336).
StandardScripts
StandardScriptscanchangethecontentsofsectionsinatemplate.Thistypeofscriptmusthavea
selector.Theselectorcanbetext,anHTMLelementand/oraCSSselector(see"SelectorsinOLCon-
nect"onpage385).
RunningaStandardScriptstartswithlookingforpiecesofcontentinthetemplatethatmatchthe
script'sselector.
Theresultsofthisquerycanvaryfromoneoccurrenceofasimpletext(forexample:@EMAIL@)toa
largecollectionofHTMLelements.Forexample,whentheselectorisp,theHTMLtagforaparagraph,
allparagraphswillbecollectedandpassedtothescript.
Tip: HoveroverthenameofascriptintheScriptspanetohighlightpartsofthetemplatethatare
affectedbythescript.
Next,thescriptcanmodifytheselectedpiecesofcontent,usingvaluesfromtherecordthatismerged
withthetemplateatthetimethescriptruns.Itcan,forexample,hide,replaceoraddtextorchangethe
styleofthosepiecesofcontent.Thisishowscriptspersonalizedocuments.
Tip: Contentaddedbyascriptisn'tvisibleinDesignmode,butisvisibleandcanbeinspectedin
Previewmode.
Note: InaPrintcontext,thescriptsintheScriptspanerunonceforeachsectionandthenonce
foreachMasterPage(seeMasterPages).
Note: Thecontextforuserscriptsdoesnotresetacrossrecords.Thismeansthatifascriptuses
avariablethatisnotdeclaredorinitializedinthatscript,thevariableretainsitsvaluefromthepre-
viousrecord.Thisisbydesign.Itallowsyou,forexample,tomaintainarunningtotalacrossall
recordsofajob.
Page 369