Conditional Merge Field Statements

Modified on Thu, 26 Jan 2023 at 05:50 PM


If you wish to hide/show sections of your document based on certain conditions then you can surround that text with conditional merge fields (IF, ELSEIF, ELSE)



In order to create a conditional statement in your document template you will need to create a merge field using the following format:

[[*IF {FirstName|pt=Client|rn=*} == "James" *]] Hello Jim [[*ENDIF*]] 


NOTE: The * denotes that we're doing something special while the IF starts the conditional statement



The standard merge fields from your merge field list should be included in braces (otherwise known as "curly brackets")


Any static values should be included in quotes and there should be an operator in front of that static value


The text that you wish to display should follow the conditional start field
Hello Steve 

Finally, you will need to include a conditional field stop


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


Note: An IF statement can not be nested within another IF statement. 



The Client's Nickname is: [[*IF {FirstName|pt=Client} == "James" *]] Jim [[*ELSEIF {FirstName|pt=Client} == "Robert" *]] Bob [[*ELSE*]] [[FirstName|pt=Client]] [[*ENDIF*]]


Be careful of Microsoft Word quotes. “James” will not work but "James" will work. (note the subtle difference in the quote characters)


Boolean Data Types

If your custom data field is a boolean (checkbox) then test against the values "true" and "false". 


[[*IF {is_approved} == "true" *]]Yes[[*ELSE*]]No[[*ENDIF*]]


Conditions Dependent on Record Number

NOTE: You are able to add a conditional field inside a repeating block of text. For more information on repeating blocks of text, see Repeating Blocks of Text.

If you have a repeating block and wish to display certain text based on the record number being generated, this can also be done with conditional merge fields.

Say I was already displaying the Full Name of all the Clients entered into my matter with the following Repeat Block:

[[*REPEAT|source=action_participant.Client|tablerow|*]] [[FullName|pt=Client|rn=*]] [[*REPEAT|END*]]


So that it generated the following result:

Sam Jones

Danielle Smith

Christine Yang

with Sam, Danielle and Christine being my Clients in the matter.


Now say I wanted 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 my table as:


BETWEEN  Sam Jones

AND            Danielle Smith

AND            Christine Yang


To produce this I could enter a conditional merge field into my repeat block depending on the record number being generated. The code I would add would be:


[[*IF {FullName|pt=Client|rn=*} == {FullName|pt=Client|rn=1} *]] BETWEEN [[*ELSE*]] AND [[*ENDIF*]]


So my full 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

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article