2022.2

Table Of Contents
Targeting elements in a cloned section
ClonesthathaveauniquenamecanbefurtherpersonalizedwiththeuseofCSSstylesheets(see
"Stylingandformatting"onpage671)andpersonalizationscripts(see"Personalizingcontent"on
page708and"Writingyourownscripts"onpage808).
Theselectortouseis:[section="name of the clone"].
ThefollowingCSSstylerulestargetthe<h1>elementinanumberofclonesandassigntherespective
textadifferentcolor:
[section="my_section_clone_0"] h1 { color: red; }
[section="my_section_clone_1"] h1 { color: green; }
[section="my_section_clone_2"] h1 { color: blue; }
Thesameselectorcouldbeusedinpersonalizationscripts:
Selector:[section="my_section_clone_0"]h1
Script:results.css('color','red');
InsideaStandardScript,clonedsectionscanbefoundusingmerge.section:
if (merge.section == "my_section_clone_0") {
results.html("Clone!");
} else {
results.html("Original.");
}
NotethatinaControlScript,merge.sectionisonlydefinedwhentheoutputchannelisWEB;see
"merge"onpage1313.
Examples
Cloning a section based on the number of records in a detail table
Thisscriptcreatesasmanyclonesofasectionastherearerecordsinadetailtable.Itassignsthenew
sectionsauniquename.
var printSections = merge.template.contexts.PRINT.sections;
var numClones = record.tables['detail'].length;
for( var i = 0; i < numClones; i++){
var clone = printSections["Section 1"].clone();
clone.name = "my_section_clone_" + i;
printSections["Section 1"].addAfter(clone);
}
Cloning a section based on data and assigning a background PDF
Thisscriptclonesasectionbasedondatafields.Itdisablesthesourcesectionfirstandthencallsthe
addPolicyfunction.addPolicyclonesthesection,renamesitandsetsaPDFfromtheresourcesasits
background.ItexplicitlyenablesthecloneandthenaddsittothePrintcontext.
Page 848