Conditions allows to define content that is either displayed or removed from the final document based on a certain condition (e.g., field values in Dynamics 365).
This step-by-step description will show you how to set conditions in our DocumentsCorePack Template Designer. In this example, we want to create a quote and choose between “Mr” and “Ms” depending on the gender of the recipient.
This webinar also covers this topic in detail.
Please note: Next to the method described in this article, Microsoft Word supports conditions inside documents that can alternatively be used.
Step 1: Create a quote template
First, we need to create the basic layout of the template, or you can use one of the existing templates. Open a Word template and click the
❶ www.mscrm-addons.com on the top of the Word ribbon and
❷ press [Insert MailMerge Fields] to open the TemplateDesigner on the right side. More information about how to create DocumentsCorePack templates can be found here.
❸ [Insert Field]-button.
Please note: Set the cursor ❹ at the position where you would like to insert a condition field. In our example, we want to set the condition in the subject line after “Dear” choosing between “Mr” and “Ms” based on the recipient like you can see highlighted in Figure 1.
Step 2: Use the Condition field option
Press the ❸ [Insert Field]-button. Select “Insert Computed Item” and then “Condition field”.
Step 3: Configure the setup of your condition fields
The Condition Field window opens. For further steps:
❶ Give your condition a descriptive name. It makes it easy to re-use existing conditions in a template.
❷ Enable the creation of an else block and define the layout of the inserted condition fields – in this case next to each other.
❸ Use the condition designer to create your condition. In this example, we want to create the condition for the entity “Potential Customer (Contact)“. We want our condition to choose between “Mr” and “Ms” depending on the gender of the recipient. Therefore, we select in the first drop-down menu the field Gender and as operator equals. Depending on the data type of the field you have an additional control that opens a new dialog to select the compare value – in this case, male. A more detailed description of the condition designer can be found here.
In your template you can see placeholders for the formatting options next to each other. Because you selected to insert an “ELSE” block you have the second placeholder like you can see in the figure below.
Step 3: Set your custom text block
Within these placeholders, you can now enter the content of your conditions. In this example, “IF” Gender equals to Male it should display “Mr” and ELSE “Ms“.
Figure 5: if and else block filled with content
Step 4: Save your template
Before you can use or test your template you have to save it. Use the [Save Template]-option of the DocumentsCorePack TemplateDesigner to publish the template to Dynamics 365.
Step 5: Test your template
As you have made changes to your template you might want to test them quickly. A step-by-step description of how to test your template can be found here. Below you can see the result of your created template containing the condition (highlighted) we set.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to firstname.lastname@example.org.