2021.2

Table Of Contents
Some knowledge of JavaScript is needed to edit Control Scripts, just as for any other self-made
scripts; see "Writing your own scripts" on the previous page. Some functionality is provided as
a Scripting Wizard, for example Conditional Print Sections.
Control Scripts don't touch the content of the sections themselves, but they change the way a
template is outputted. For more information about Control Scripts and their use, see "Control
Scripts" on page913.
Standard Scripts
Standard Scripts can change the contents of sections in a template. This type of script must
have a selector. The selector can be text, an HTML element and/or a CSS selector (see
"Selectors in Connect" on page898). Running a Standard Script starts with looking for pieces
of content in the template that match the script's selector.
The results of this query can vary from one occurrence of a simple text (for example:
@EMAIL@) to a large collection of HTML elements. For example, when the selector is p, the
HTML tag for a paragraph, all paragraphs will be collected and passed to the script.
Tip
Hover over the name of a script in the Scripts pane to highlight parts of the template that
are affected by the script.
Next, the script can modify the selected pieces of content, using values from the record that is
merged to the template at the time the script runs. It can, for example, hide, replace or add text
or change the style of those pieces of content. This is how scripts personalize documents.
Note
In a Print context, the scripts in the Scripts pane run once for each section and then once
for each Master Page (see "Master Pages" on page506).
Tip
Content added by a script isn't visible in Design mode, but is visible and can be
inspected in Preview mode.
Page 878