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

Suppressing empty lines

Suppressing empty lines

Suppose you have an address captured as four separate data elements. Typically the Address section of a letter would then look like:

<<AddressLine1>>
<<AddressLine2>>
<<AddressLine3>>
<<AddressLine4>>
<<PostalOrZipCode>>

But sometimes the fourth, or maybe even the third, lines are empty, and you normally don’t want to leave an empty line between the last non-empty address line and the PostalOrZipCode.
Here is what to do:

<<AddressLine1>>
<<AddressLine2>>
<<ShowIfHasValue(AddressLine3)>>
<<ShowIfHasValue(AddressLine4)>>
<<PostalOrZipCode>>

When a template like this is run, if the AddressLine3 data element is empty, then the entire line on which the fillpoint <<AddressLine3>> appears will be removed from the merged document. The same applies to <<AddressLine4>>.

Prior to version 3.9.3 (when the ShowIfHasValue function was introduced), the way to achieve the suppression of empty lines was as follows (shown here in case you have seen code like this in templates)

<<AddressLine1>>
<<AddressLine2>>
<<If(AddressLine3 != “”)>>
<<AddressLine3>>
<<End()>>
<<If(AddressLine4 != “”)>>
<<AddressLine4>>
<<End()>>
<<PostalOrZipCode>>

 Notes:

  • When an If command is the only text in a paragraph, then that paragraph will not appear in the merged document. The same applies to the End() command (and numerous other commands, e.g. ForEach, Else(), and the various ChooseFrom... commands, etc.) which, when they are the only text in a paragraph, will result in that entire paragraph being removed from the merged document.
  • The symbol != means “is not equal to”.

Leave a Reply