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

Define layout in a base template

Define layout in a base template

Sometimes a letterhead needs to dictate not just things like the company’s logo and fairly static items like the directors’ names, but also the position of the addressee information and data elements like ‘Your Reference’ and ‘Our Reference’, for example.

These latter items will differ from one letter to another and therefore need to take the form of fillpoints on the letterhead template itself.

For sake of argument, suppose it is the addressee information that is required to start in a specific location in the letter head. This can be achieved by putting fillpoints into those specific locations, and a snippet of the letterhead would then look like this:

<<Addressee>>
<<AddressLine1>>
<<AddressLine2>>
<<AddressLine3>>
<<PostalCode>>
<<DocumentBody>>

Note that in the letterhead example the statement was made that all templates using the letterhead via a <<BaseTemplate>> command would contain the addressee fillpoints, greeting and salutation, etc.

In other words the placement of those fillpoints on the letterhead would be dictated by the originating template, not the base template.

In this new scenario, the originating templates would obviously not have the addressee information on them (otherwise that information would be duplicated in the merged document).

Suppose we now have a small application, and we are going to be running templates and re-using the data sets captured for previous templates. In this application there are a number of templates for letters, some of which need to be addressed to the ‘buyer’ and some to the ‘seller’.

Suppose too that there are some documents, such as an agreement, that require the address information of both buyer and seller to appear on them. This means that the data set for the agreement would have data elements like ‘BuyerName’, ‘BuyerAddressLine1’, ‘BuyerAddressLine2’, etc. and similar names for the seller so that they could be referred to on the agreement by the correct data element names.

The issue is now this: How are we going to use the same letterhead to be a BaseTemplate for letters to the buyer as well as to the seller, when the fillpoints on the letterhead are <<Addressee>>, <<AddressLine1>>, etc. when sometimes we would wish them to be <<BuyerName>>, <<BuyerAddressLine1>>, etc. and sometimes <<SellerName>>, <<SellerAddressLine1>>, etc.?

This is done with the <<ReplaceField()>><<ReplaceFieldEnd()>> commands which are coded into the originating template.

A typical template addressed to the buyer would previously have looked something like this:

<<BaseTemplate(Letterhead)>>
<<BuyerName>>
<<BuyerAddressLine1>>
<<BuyerAddressLine2>>

Dear Sir
Various issues have arisen of interest to buyers.
Yours Faithfully

Using the new letterhead template, which has the addressee information on it, the new originating document would look like this:

<<BaseTemplate(Letterhead)>>
<<ReplaceField(Addressee)>><<BuyerName>><<ReplaceFieldEnd()>>
<<ReplaceField(AddressLine1)>><<BuyerAddressLine1>><<ReplaceFieldEnd()>>
<<ReplaceField(AddressLine2)>><<BuyerAddressLine2>><<ReplaceFieldEnd()>>
<<ReplaceField(DocumentBody)>>

Dear Sir
Various issues have arisen of interest to buyers.
Yours Faithfully

<<ReplaceFieldEnd()>>

The <<ReplaceField(XXX)>> command means this:

In the base template, find the fillpoint <<XXX>> and replace that fillpoint with whatever is between this ReplaceField command and its matching ReplaceFieldEnd().

Note that the ‘DocumentBody’ fillpoint now also needs a <<ReplaceField(DocumentBody)>> and a <<ReplaceFieldEnd()>>. This is the case whenever there are any ReplaceField commands in a template – what was initially the entire document body now needs to be enclosed in a <<ReplaceField(DocumentBody)>> and <<ReplaceFieldEnd()>> pair.

Note that a <<ReplaceField>> cannot appear after a <<ReplaceFieldEnd()>> if the two are in the same paragraph.

Note also that just about anything (other than <<BaseTemplate>> and another <<ReplaceField()>>) can appear between a <<ReplaceField()>> and <<ReplaceFieldEnd()>>.

For example, it might be that we can infer from the seller’s address what the postal code should be, then we could do something like:

<<ReplaceField(PostalCode)>><<If(SellerAddressLine2 = “Pinelands”)>>7405<<Else()>><<If(SellerAddressLine2=”Observatory”)>>7935<<Else()>><<PostalCode>><<End(observatory)>><<End(pinelands)>><<ReplaceFieldEnd()>>

Then, regardless of what the user enters for ‘PostalCode’, when the suburb is ‘Pinelands’ or ‘Observatory’, the correct postal code will be merged into the document.

Of course, in real life the second line of the address might not be the suburb, but this example at least illustrates the power of the ReplaceField command.

Leave a Reply