Tutorial Videos

Tutorial videos are available here.

Knowledge Base

Visit our User Forum for discussions & solutions

Inserting templates with variable names (Part 2)

The original article regarding inserting documents with variable names was written way back in 2009.  Since then, as a result of further maturing of XpressDox, some really useful innovations have been added.  In particular, if there are data elements whose values are set very early in the process (in fact before step 1 in The Processing Phases of XpressDox), then this opens a few interesting possibilities.

The first question is how can data elements get values set before Phase 2 in the above-mentioned Processing Phases?  Firstly, the data elements can be part of the Standard Data defined in the XpressDox configuration.  In particular, it is possible for a person licensed as a Supervisor to configure a data source who data can be regarded as Standard Data.  This is described in the document XpressDox Supervisor Guide.doc which is delivered with XpressDox into the folder My Documents\XpressDox when XpressDox is installed on the desktop.

The other way to get data initialised before a template is run is to use the interview from one template to capture the information, and then use the MergeTemplate function in that template to run a second template. The data captured in the merging template are then all known before the merged template is run.

Now, in the case where data elements have values before a template is run, the BaseTemplate and IncludeTemplate commands in that template can refer to templates whose file names are built up from one or more data elements.  The syntax is, for example:

«IncludeTemplate(Signature <UserName>)»

There is an issue with this, and that is that perhaps the entry of the UserName value is left to a user (capturing the value in an interview) and that is open to someone entering the name of a user that does not exist, or at least for a user for whom there is no Signature file.  This would result in an error message and the assembly of the final document would be aborted.  But this format of IncludeTemplate can be specified with a condition, for example:

«IncludeTemplate(Signature <UserName>,,,,FileExists('Signature ',<UserName>))»

In other words, if the file does not exist, then the command is not executed, and no error is issued.

Then, a default “signature” could be included for the case where the signature file for a specific UserName does not exist:

«IncludeTemplate(Signature <UserName>,,,,FileExists('Signature ',<UserName>))»
«IncludeTemplate(DefaultSignature,,,,not(FileExists('Signature ',<UserName>)))»

Note that the above example is not the same as:
«If(FileExists(concat('Signature',UserName)))»«IncludeTemplate(Signature <UserName>)»«End()»
XpressDox will attempt to Include template Signature <UserName> regardless of whether the template exists or not, and only apply the condition after that.