2022.1

Table Of Contents
since it gets removed when the table is expanded, which happens before template scripts run.
The data-script attribute is used if you let the Designer create a script for you (see "Quick-start
a script with the Create script button" on page951).
How the scope of a script can simplify code
It is recommended to set the scope of a script that targets (an element in) dynamically added
rows to Each matched element.
The selector of a script that targets (something in) a row that is linked to a detail table will
probably match multiple elements.
By setting the scope of a script you can determine whether you want to run the script once, or
once for each element that matches the selector. (See "Setting the scope of a script" on
page924.)
If a script runs once, accessing the detail data and dynamically added rows tends to be bit
complicated, especially when they are nested, since it involves looping over the results and
record objects (see "results" on page1509 and "record" on page1381).
If a script targets (something in) a row that is bound to a detail table, and runs once for each
matched element, the current element is accessible via the this object (see "this" on
page1425) and the current detail record is accessible via this.record.
The advantage of the latter approach is demonstrated in the example below.
Example: Styling a row based on a value in a detail table
Here are two scripts that have the same effect:if in a row, the value of the field Shipped is 1, it
colors the text of that row green.
The first script targets a cell in a Dynamic Table row that is bound to a detail table. The script
has its scope set to "Each matched element", so it can use this (see "this" on page1425) to
Page 953