2022.2

Table Of Contents
Thefollowingscripttargetsthetable,andhasitsscopesetto"Resultset".Thisscriptloopsoverthe
detailtableintherecord,evaluatingthefieldShipped.Ifthevalueofthatfieldis1,itlooksupthecor-
respondingrowintheresults(theselectedDynamicTable).
Selector:#table_1tbody
Scope:Resultset
for(var i = 0; i < record.tables.detail.length; i++){
if(record.tables.detail[i].fields['Shipped'] == 1)
query("tr:nth-child(" + (i+1) + ")", results).css('color','green');
}
Control Scripts
Whenoutputisgeneratedfromatemplate,ControlScriptsrunbeforeallotherscripts,whenarecordis
mergedwithacontext.Theydeterminehowdifferentsectionsofthecontextarehandled.Theycan,for
example,makethepagenumberingcontinueoverallPrintsections,splitEmailattachments,oromit
Printsectionsfromtheoutput.
SomefunctionalityisprovidedasaScriptingWizard,forexampleConditionalPrintSections.
ThistopicexplainshowtoaddaControlScriptanditgivesanoverviewofwhatControlScriptscando.
Itwillalsotellyouwhereyouwillfindinformationabouteachfeature,includingexamples.
Thebasicsofscript-writingintheDesignerareexplainedinthefollowingtopic:"Writingyourown
scripts"onpage808.
WhatControlScriptsare
ControlScriptsareaspecialkindofDesignerscript.Theycanmanipulatethewayoutputisgenerated
fromatemplate.Theyallowyou,forexample,tochangethepagenumberinginPrintoutput,tosplit
onegeneratedPrintdocumentintomultipleEmailattachments,ortosetaPrintsection'sbackground
dynamically.(Theseareonlyafewexamples;formoreusesofControlScriptssee"WhattouseaCon-
trolScriptfor"onthenextpage.)
ControlScriptsdifferfromStandardscriptsintwoways:
l
ControlScriptsrunbeforeallotherscripts.Whenatemplateconsistsofseveralcontexts,and
thesecontextsarecombinedintheoutput-forexample,whenanEmailisgeneratedwiththe
Printcontextasattachment-allscriptsrunonceforeachcontext,butControlScriptsalwaysgo
first.
l
ControlScriptsdo not touch the content-meaning,thetextflow-ofthesections.
Theydon'thaveaselector,liketheotherscriptsdo.Aselectorselectspartsofthecontentofa
sectionandstoresthemintheresultsobject,sothattheycanbemodifiedinthescript.AsCon-
trolScriptsdon'thaveaselector,theresultsobjectcan'tbeusedthere.
Page 838