Suppressing empty lines in your assembled document – XpressDox

Blank lines in your XpressDox template

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


«AddressLine1»
«AddressLine2»
«City»
«State»
«ZipCode»

But sometimes the second line is empty, and you wouldn’t want to leave an empty line behind in your document. And so, here is what you can do to ensure that won’t happen!


«AddressLine1»
«ShowIfHasValue(AddressLine2)»
«City»
«State»
«ZipCode»

When a template like this is run, if the AddressLine2 data element is empty, then the entire line on which that data element appears will be removed from the assembled document.

 

Write the above as an XpressDox script

Visit this post on Scripts to learn how to re-use text in your template, and stop the need for repetitive typing!

 

Other reasons why you might have empty lines in your assembled document:

  1. When you have multiple XpressDox commands on the same paragraph, blank lines tend to be left behind after the template has run. Each command should be placed on its own paragraph.
  2. Using SetV when you could use SetVr. SetVr removes the paragraph. Be careful not to use SetVr when you have other text on the same paragraph though; the entire paragraph will be removed!
  3. The SendWebEmail command leaves behind an empty paragraph. You can fix this by placing a RemoveParagraph on the same paragraph. But there is a better way to do emails now with the invention of SendAsEmail (from v14).
  4. If you are using a version of XpressDox earlier than v14, then CreateDataElement also leaves behind an empty paragraph. Put a RemoveParagraph command on the same paragraph.

 

Note:

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.