2022.1

Table Of Contents
var records = record.tables.detail;
for (var i = 0; i < records.length; i++) {
var rec = records[i];
...
}
Examples
record.fields
The following Standard Script evaluates the data field Country in the current record. If the value
is 'CANADA' it will show the results, otherwise it will hide them. (The results object contains the
elements that match the script's selector; see "results" on page958 and "Writing your own
scripts" on page389.)
if (record.fields["Country"] == "CANADA") {
results.show();
} else {
results.hide();
}
Instead of record.fields["Country"] you could write record.Country (case sensitive), if there
is no detail table with the same name.
In a Control Script, an entire section could be enabled or disabled based on the same
condition:
if (record.Country == "CANADA") {
merge.template.contexts.PRINT.sections["Section 1"].enabled =
true;
} else {
merge.template.contexts.PRINT.sections["Section 1"].enabled =
false;
}
(For more information about Control Scripts, see "Control Scripts" on page425.)
record.tables
The next script looks up a value in the first record in a detail table called "detail" and shows or
hides the results depending on that value.
if (record.tables.detail[0].fields.prod_id == "10") {
results.show();
Page 836