7.6 Creating a Document Template with an IF block
This lesson will show you how to create more complex document templates using IF blocks. Before you try this, you should know how to create a simple template, which you can find here.
Creating an IF block
A more complex kind of mergefield is an IF block.
This allows you to create if statements that will generate different outcomes depending on whether or not the IF condition is satisfied.
For example the if block in this field is: {IF {MERGEFIELD Contact.PrimaryClient.Name} <> "" "and our primary contact in your organization {MERGEFIELD Contact.PrimaryClient.Name}"}. This means that if the primary client name is not equal (<>) to blank ("") then the result "and our primary contact in your organization {MERGEFIELD Contact.PrimaryClient.Name}" will be generated in the document.
In this case the IF block is allowing you to add additional contextual text to take in to account the existence of a primary client.
To create an IF block, first press alt+F9 to activate mail merge mode then ctrl+F9 to create a field. Enter IF, then enter you condition, in this case "{MERGEFIELD Contact.PrimaryClient.Name} <> "" ". After this enter the result inside quotation marks. Following this format you can create increasingly complex IF statements that will react to different case information in a contextual manner.
The following examples show the result of an IF block when the condition is, and is not, satisfied.
Outcome when condition is satisfied
This example has been generated when the case has a primary client. You can see the text prescribed in the IF block is also generated as the condition has been satisfied
Outcome when condition is not satisfied
In this example the primary client has been removed so the IF condition is not satisfied. As a result the prescribed text is not generated either, completely removing any mention of the primary client.