Use Google to find help fast. For example, search on "xpressdox choosefromlist".

Provide default values

Provide default values

Often there is a need (for you as template author) to require that the user provide values for data elements, but that those data elements usually have the same value from one template run to another, and only change for exceptions. That means that you would like the system to provide the user with default values, but allow the user to change them for any specific situation.

An example of such default values would be a discount percentage, or an amount such as a consultation fee. A typical paragraph in a template might then read:

The fee for this consultation is $<<FormatNumber(ConsultationFee)>>, but a discount of <<DiscountPercent>>% will be applied if the account is settled in full within 14 days of receipt hereof.

When a template with this paragraph is run, then the user will be presented with capture fields for ConsultationFee and DiscountPercent, but by default both of these fields will be empty.

Providing default values for those fields would be achieved as follows (assuming the default for the fee of $450 and the discount as 10%):

a. Create a text file which has two lines in it, and looks like this:

ConsultationFee,DiscountPercent
450,10

b. Save the file in the same folder as the template, and call it Defaults.xdtxt.

c. In the template itself, put the following command in a paragraph by itself:
<<IncludeFileData(Defaults.xdtxt,norefresh)>>

Those defaults (i.e. $450 and 10%) will be applied when the template is run with “New Data”.

The “norefresh” parameter ensures that when the data set for this template are used subsequently, the default data from the defaults file will not be refreshed in the data set. For a fuller explanation of “norefresh”, please see Get information from a data source and also Control how the user can change data source data .

A note about text files: these can be created using NotePad, or even Microsoft® Office Word. When creating a text file in Word, type the file as you normally would, and then save it using the “Save As” feature, and choose “Plain Text (*.txt)” in the “Save as type” drop-down box.

The file Defaults.xdtxt could be saved, not in the template folder, but in a Helper Folder (see Configuring Helper folders). Suppose the alias for this Helper Folder is lookups, then the fillpoint would read <<IncludeFileData(lookups:Defaults.xdtxt,norefresh)>>.

Even though the SetInitialValue command can be used to code the default values in the template itself, but the above mechanism using IncludeFileData allows the default values to be changed without the need to change the template. This is particularly useful in the situation where a number of templates share the same data elements with the same default values. In that case changing the default values in the included text file will apply those default values in all including templates.

Leave a Reply