record

The record object gives access to the record that is currently being merged with the template.

Properties

Field Type Description
fields

Array

The field values that belong to this record. You can access a specific field value using either a numeric index or the field name: record.fields['fieldname'] or record.fields.fieldname.

id

Number

The id of this record.

index Number

The one-based index of this record, or zero if no data is available.

tables Array

The detail tables that belong to this record. You can access a specific table using either a numeric index or the table name, followed by a numeric index for a record inside that detail table. For example, to access the value of the field prod_id in the first record of a detail table called detail, use: record.tables["detail"][0].fields["prod_id"].

Examples

The following template 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 and Writing your own scripts.)

if (record.fields["Country"] == "CANADA") {
results.show();
} else {
results.hide();
}

In a Control Script, an entire section could be enabled or disabled based on the same condition:

if (record.fields["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.)

The next script looks up a value in the first record in a detail table and shows or hides the results depending on that value.

if (record.tables["detail"][0].fields["prod_id"] == "10") {
results.show;
} else {
results.hide;
}

Note that indexes start counting at 0, so tables["detail"][0] refers to the first record in the detail table.

 
  • Last Topic Update: 03, July, 2017 05:53 AM
  • Last Published: 23, May, 2019 01:55 PM