Include data from an external file into your interview
Use case:
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.
Create a text file:
Providing default values for those fields would be achieved as follows (assuming the default for the fee of $450 and the discount as 10%):
Firstly, create a text file which has two lines in it, and looks like this:
ConsultationFee,DiscountPercent
450,10
Now save the file and call it Defaults.xdtxt. It can be saved in the same folder, or better yet a different folder and in the IncludeFileData command referenced using a helper folder
The IncludeFileData command on your template:
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)»
.