Sometimes it would be useful to be able to customize a source template for more than just the letter body. For example, it may be that the Data Set contains data for more than one set of addressees and the source document needs to be able to indicate which of these addressees is to be included on the base template.
This can be achieved using a ReplaceField
command:
«BaseTemplate(Letterhead.xml)»
R.J. Smith-Jones
«ReplaceField(Addressee)»«DebtorName»«ReplaceFieldEnd()»
«ReplaceField(AddressLine1)»«DebtorAddressLine1»«ReplaceFieldEnd()»
«ReplaceField(AddressLine2)»«DebtorAddressLine2»«ReplaceFieldEnd()»
«ReplaceField(FeeEarner)»«ReplaceFieldEnd()»
«ReplaceField(DocumentBody)»
We note that your account is now overdue by an amount of«BalanceOutstanding»
.
Please make sure that payment is made forthwith.
«ReplaceFieldEnd()»
Some notes:
a. When using the ReplaceField
command for any of the base template fillpoints, the ‘DocumentBody’ fillpoint must be specified, that is there is no default for it in this situation, unlike when no ReplaceFields
are used, in which case the ‘DocumentBody’ is the entire originating template, excluding the BaseTemplate
fillpoint.
b. Note the replacement of the ‘FeeEarner’ fillpoint: It is replaced not with another field but with the constant text ‘R.J. Smith-Jones’. This would be the situation where the source template is only ever used by a particular fee earner, and so the destination template needs to reflect that fee earner, and not any fee earner which may be in the data set.
c. When a ‘skeleton’ letter is based on a letter head (a ‘skeleton’ typically containing only the addressee information and salutation and closing), then the template author would like the user to be prompted in some way to fill in the remainder of the letter body manually. This is what the ComeHereAfterRun
command was designed for – after a template is run then this command will cause the Word cursor to position at the point in the document where it appeared:
«Addressee»
«Address1»
«Address2»Re:
«ReForLetter»
«ComeHereAfterRun()»
Yours faithfully