2022.2

Table Of Contents
Tosetthescopeofascript,clickonOptionsatthebottomoftheScriptEditorwindow.Theoptionsare:
l
Result set:Thescriptwillrunonce,regardlessofthenumberofelementsthatmatchthe
selector.Itwillhaveaccesstoallelementsthatmatchtheselectorviatheresultsobject(see
"results"onpage1301).Theeach()functioncouldbeusedtoiterateoverelementsintheres-
ults.
l
Each matched element:Thescriptrunsonceforeachelementthatmatchestheselector.The
currentelementisaccessibleviathethisobject(see"this"onpage1237).Ifthescripttargets
(somethingin)arowthatisboundtoadetailtable,thecurrentdetailrecordisaccessiblevia
this.record.
Note: ThescopeofControlScriptscan'tbeset,becausetheydon'thaveaselector.
Managing scripts
Changingtheorderofexecution
Whenarecordsetismergedwithatemplatetogenerateoutput,allscriptsareexecutedonceforevery
recordintherecordset,intheorderinwhichtheyappearintheScriptspaneatthebottomleft.
Theorderinwhichscriptsareexecutedisparticularlyimportantwhenonescriptproducescontentthat
containsaselectorforanotherscript.Iftheotherscripthasalreadybeenexecuted,itwillnotrunagain
automatically.So,scriptsthatproducecontentthatcontainsoneormoreselectorsforotherscripts,
needtocomefirst.
Tochangetheorderinwhichscriptsareexecuted:
l
ClickascriptorafolderintheScriptspaneatthebottom.Dragitupordownanddropit.
Note: Controlscriptsarealwaysexecutedfirst,regardlessofwheretheyareintheScriptspane.
Theycannotbeexcludedfromexecutionforaspecificcontextorsection,usingtheexecution
scopeofafolder;see"Executionscope"onthenextpage.Whatyoucandoisdisablethescript
orthecontainingfolder;see"Enable/disablescripts"onpage816.
Scriptfolders
Scriptscanbeorganizedinfolders.Whywouldyoudothat?Forthreereasons:
l
Foldershaveanexecutionscope.Youcanspecifyforwhichcontextsandsectionsthescriptsin
afolderhavetorun.
l
Foldersprovideabetteroverviewthanalongunorganizedlistofscripts.
l
Foldersmakeiteasiertochangetheorderofexecutionforabunchofscripts(see:"Changingthe
Page 814