2022.2

Table Of Contents
Example:Stylingarowbasedonavalueinadetailtable
Herearetwoscriptsthathavethesameeffect:ifinarow,thevalueofthefieldShippedis1,itcolors
thetextofthatrowgreen.
ThefirstscripttargetsacellinaDynamicTablerowthathasa[data-script='Shipped']attribute.The
scripthasitsscopesetto"Eachmatchedelement",soitcanusethis(see"this"onpage781)toaccess
theselectedcellandthis.recordtoaccessthecurrentdetailrecord,withoutperforminganyloops.
Selector:table[data-script='Shipped'].
Scope:Eachmatchedelement
var field = this.record.fields['Shipped'];
if (field == 1)
this.parent().css('color', 'green');
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.
Page 397