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

Implement an optional option with ReplaceField

Implement an optional option with ReplaceField

In the article Define layout in a base template, a mechanism for hard-wiring various fields in a letterhead base template is discussed.

Now suppose that it’s not a letterhead that is the base, but the outline of an agreement on which other agreements will be based.  In this base agreement you would have constructs like a table of contents, a cover page, a table of appendices, etc.

For simplicity of illustration purposes, we will consider just the option of whether the firm’s logo should appear on the final document or not.

Before going further, let’s establish this outline, in a template called “BaseAgreement.xdptx”:

«ChooseUsingCheckBox(Include_Logo,Y,N,N)»
«Caption(Include_Logo,Include the firm’s logo in the agreement?)»
«If(Include_Logo = ‘Y’)»«IncludeTemplate(LogoTemplate)»«End()»

«ToUpper(AgreementName)»

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.


Then, originating templates for all agreements would start off with

«BaseTemplate(BaseAgreement)»

on the first line.

If no other steps are taken, then a checkbox with caption “Include the firm’s logo on the agreement?” will appear on the interview.

Now, suppose that for some agreement templates, you don’t want the user to be given the option of a logo  – in other words you either want the logo to be included every time a particular template is run, or, conversely, the logo should never appear when certain other templates are run.

In those cases, you don’t want the check box to appear on the interview, and you want to either force the logo to appear, or force it not to appear.

There are a number of ways to achieve this, but here are two (actually one, with two variations).

Scenario one – the logo must always appear

In the originating template, have the following:

«BaseTemplate(BaseAgreement)»

«ReplaceField(If(Include_Logo = ‘Y’))»«If(1 = 1)»«ReplaceFieldEnd()»

«ReplaceField(DocumentBody)»
… rest of originating template.
«ReplaceFieldEnd()»

Notice that the «If» command is replaced by an If with a condition that will always be true (because 1 = 1 is always true).  Also, since the end result of the ReplaceField command is that the value of the data element Include_Logo is no longer required, the effect on the interview is that the data element will not show (even though there is a ChooseUsingCheckBox and a Caption referring to it – the relevance rules dictate that it will not be required).

Scenario two – the logo must never appear

The originating template will now look something like this:

«BaseTemplate(BaseAgreement)»

«ReplaceField(If(Include_Logo = ‘Y’))»«If(1 = 2)»«ReplaceFieldEnd()»

«ReplaceField(DocumentBody)»
… rest of originating template.
«ReplaceFieldEnd()»

Notice the condition “1 = 2” in the If command – it will always be false.

Leave a Reply