Conditional Mail Merge Templates with Zocuments

Conditional Mail Merge Templates with Zocuments

Templates can be created with conditional logic that changes the output document based on the values of different merge fields.

Conditional expressions perform different actions depending on whether a statement is true or false.

conditional if statement syntax:

if Gender = "male"

Two or more conditions can be tested in one if statement:

if Gender = "male" and Age < 65

conditional statements in document templates:

{{ if Gender = "male" }}Mr{{ endif }}

Supported Operators

Operators define how terms relate to each other; are they the same, or not?

Operator Description Use With
= Equal to Text and numeric expression
!= Not equal to Text and numeric expression
> Greater than Only on numerical expressions
< Less than Only on numerical expressions
<= Less than or equal to Only on numerical expressions
>= Greater than or equal to Only on numerical expressions

Conditional Keywords

Keyword Description
if Executes a statement if a specified condition is truthy
elseif Specify a new condition to test, if the previous condition is false
else Specify a statement to execute, if the previous condition is false
endif Terminate a corresponding IF keyword block

Putting it All Together in Your Document Template:

{{ if Time < 10 }}
Good Morning!
{{ elseif Time < 20 }}
Good Afternoon.
{{ else }}
Good Evening
{{ endif }}

if 5 is provided as the merge value for Time the generated document text would be:

Good Morning!

if 18 is provided as the merge value, the generated document text would be:

Good Afternoon.

if no value, or 23 is provided, the generated document text will be:

Good Evening
Show Comments