In this article:
- Creating Conditional Statements
- Using Boolean Data Types
- Using Conditional Statements in Repeat Blocks
If you need to hide or show sections of your document based on certain conditions, you can surround that text with conditional merge fields (IF, ELSEIF, ELSE).
Creating Conditional Statements
In order to create a conditional statement in your document template, you must create a merge field using a very specific format.
Example 1
[[*IF {FirstName|pt=Client|rn=*} == "James" *]] Hello Jim [[*ENDIF*]]
The following examines each part of this conditional merge field:
[[*IF
The double brackets with the asterisk indicate that this is a conditional statement.
{FirstName|pt=Client|rn=*}
The standard merge fields from your merge field list should be included in braces (otherwise known as "curly brackets")
="James"]]
Any static values should be included in quotes and there should be an operator in front of that static value
Hello Jim
The text that you wish to display should follow the conditional start field
[[*ENDIF*]]
Finally, you will need to include a conditional field stop
Example 2
You can add any number of ELSEIF options for additional conditions and ELSE section as a catch-all if all prior IF/ELSEIF conditional are false:
The Client's Nickname is: [[*IF {FirstName|pt=Client} == "James" *]] Jim [[*ELSEIF {FirstName|pt=Client} == "Robert" *]] Bob [[*ELSE*]] [[FirstName|pt=Client]] [[*ENDIF*]]
- An IF statement cannot be nested within another IF statement.
- Quoted text must use straight quotes and not curly quotes.
Using Boolean Data Types
If your custom data field is a Boolean (or checkbox), you can use a custom Boolean (or checkbox) field to merge text based on whether the value is "true" and "false".
Example:
[[*IF {is_approved} == "true" *]]Yes[[*ELSE*]]No[[*ENDIF*]]
Using Conditional Statements in Repeat Blocks
If you have a repeating block and want to display certain text based on the record number being generated, this can also be done with conditional merge fields.
For example, say you need to display the Full Name of all the clients associated with a matter. To do this, you've set up the following repeat block:
[[*REPEAT|source=action_participant.Client|tablerow|*]] [[FullName|pt=Client|rn=*]] [[*REPEAT|END*]]
When merged, this block might insert the following list of clients for the matter:
Sam Jones
Danielle Smith
Christine Yang
Now, let's say you want the text BETWEEN to appear before the first client's name, and the text AND to appear before every other client's name, so that it generated in a table, like this:
BETWEEN | Sam Jones |
AND | Danielle Smith |
AND | Christine Yang |
To create a list like this, add a conditional merge field in the repeat block depending on the record number being generated., like this:
[[*IF {FullName|pt=Client|rn=*} == {FullName|pt=Client|rn=1} *]] BETWEEN [[*ELSE*]] AND [[*ENDIF*]]
The complete merge field—including the repeat block—would be:
[[*REPEAT|source=action_participant.Client|tablerow|*]][[*IF {FullName|pt=Client|rn=*} == {FullName|pt=Client|rn=1} *]] BETWEEN [[*ELSE*]] AND [[*ENDIF*]] [[FullName|pt=Client|rn=*]] [[*REPEAT|END*]]
Related Articles:
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article