Open topic with navigation
Conditional statements execute different "branches" of code, depending on how a conditional expression is evaluated. Accordingly, some code may not be executed, depending on the conditions at the time of the evaluation. This can cause a problem if a reference to a field or share name happens to be in code that gets skipped during the test run of its scripts. If the associated conditional statement evaluates differently at print time and causes the field or share name to be referenced, and if it was not referenced during the previous test run, the script may not run at the most efficient time and may even fail.
The Script Editor includes two functions that force a script to reference a database field or data source name: ReferenceField and ReferenceSharedSubString. These functions don't change or assign any values. They simply force the application to notice the presence of an item that could be missed during the test run of a script.
To find the two forcing functions in the Script Editor
In the Script Assistant pane, expand the Functions book.
Under Functions, expand the Declarations book. There you will see two sub-books, ReferenceField and ReferenceSharedSubstring.
The reference functions are best inserted into the beginning of your script before any conditional statements.
The ReferenceField sub-book will be available only if your template is connected to a database.
You can force a VBScript to reference a database field or named data source.
To force reference to a Database Field
In the Script Assistant pane, open Functions > Declarations > ReferenceField.
Double-click the name of the data file field you wish to force. A code snippet will appear in the Script pane:
If the document is set up to read data from a regular text file, you will specify a field number. When reading from a database, you will specify a field name. Unless the field name itself is contained in a variable, be sure to put the name in quotes, such as ReferenceField("price").
To force reference to a Named Data Source
In the Script Assistant pane, open Functions > Declarations > ReferenceSharedSubString.
Double-click the named data source you wish to force. A code snippet will appear in the Script pane:
If you have given any data sources in the template a name, you can force reference to them as shown above. (Unless the data source name is stored in a variable, enclose the name in quotation marks.)