2021.2

Table Of Contents
However, if the contents or style of cells or rows in a Dynamic Table need to be personalized
based on the value of a field, you will need a script.
This topic gives some information that will help you to write a script for (an element in) a
Dynamic Table.
It is assumed that you are familiar with the scripting basics; see "Writing your own scripts" on
page877.
Quick-start a script with the Create script button
The easiest way to add a script that targets a specific element (usually a cell or span) that is
linked to a data field in a detail table, is this:
1. In Design mode, select the element.
2. Click the Create Script button next to the Field drop-down on the Attributes pane.
3. Click Yes.
As a result:
l The element's data-field attribute will be renamed to data-script.
l If the element had a data-format attribute, that attribute will be removed.
l A new script will be created and opened in the Script Editor.
The selector of the new script is the data-script attribute with the name of the data field that
the element was linked to as its value. For example: table [data-script='ID'].
The code of the script replaces the contents of the element with the current value of the data
field:
var field = this.record.fields['ID'];
if (field) {
this.text(formatter.upperCase(field));
}
The scope of the script is set to Each matched element (see "Setting the scope of a script" on
page883). This means that in the code, this refers to the element that matches the selector,
and this.record refers to the current (nested) detail record (see "this" on page1364).
Page 910