Certain properties of DocumentsCorePack templates consist of conditions based on Dynamics 365 fields. The Condition field property allows you to define dynamic content that is either displayed or removed from the final document based on a certain condition.
This step-by-step description will show you how to set conditions in 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.
Step 1: Create a quote template
First, we need to create the basic layout of the template. Clicking on the [Insert MailMerge Fields]-button in the www.mscrm-addons.com command bar will open the DocumentsCorePack Designer on the right side. More information about how to create DocumentsCorePack templates can be found here.
The figure below shows an example template of a quote.
Step 2: Use the Condition field option
After creating your template, please 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 yellow in the figure above. Then, go to Insert Computed Item and select Condition field.
Figure 2: Insert Condition field
Step 3: Configure the setup of your condition fields
❶ 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 “Primary Contact (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 either have an additional control that opens a new dialog to select the compare value – in this case, Male.
Below 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: Custom text block
Step 4: Save your template
Before you can use or test your template you have to save it. Either you save your template locally with the standard or the functionality of Word or you use the -option of the DocumentsCorePack client in order to publish the template to Dynamics 365.
Step 5: Test your template
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to firstname.lastname@example.org.
#reworkneeded… we have a lot of articles about conditions.. reference them or/and merge