mscrm-addons.com logo displayed here.mscrm-addons.com logo displayed here.
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
home/Knowledge Base/Template Designer(DCP)/If/else-conditions in *.docx templates

If/else-conditions in *.docx templates

6681 views 2 Updated on January 28, 2025

It is often required to place conditional fields within a template like e.g. only print address lines when stored in the regarding CRM-record.


Syntax

The syntax needed is pretty simple:

{if”<>”=”XY” “Content if condition is fulfilled” “Content if condition is not fulfilled”}

while the yellow part marks the condition, the green part marks the content that will be printed if the conditions is fulfilled and the red part marks the content that is printed if the condition is not met.

Please note: The {} (brackets) are not just simple standard wavy-brackets; they are field-functions of MS Word and you have to insert them by pressing Ctrl+F9 or via Insert -> Quick Parts -> Field and selecting ‘if’..

MS Word does not show field functions by default. To switch views, you can simply press Alt + F9.

Examples:

Printing a gender-specific salutation:
Dear {if”<<salutation>>”=”Mr.” “Mister” “Misses”} <<lastname>>

Showing fields only if available within CRM:
{if”<<emailaddress1>>”<>”” “Email: <<emailaddress1>>” “”<emailaddress1> }
{if”<<mobilephone>>”<>”” “<<mobilephone>>”}

Find an example here.

Common problems

  • You cannot insert field-code brackets inside a content control, so please ensure you do not mark the content control of the CRM-field when trying to insert the {}-brackets.
  • For some reasons it is not possible to insert the brackets even outside the content-controls once there is nothing else than the content-control in the whole line. To overcome this issue you can simply insert any text or a space after or before the field and than insert the {} brackets.
If/else-conditions in *.docx templates

You cannot insert the {} in the upper line of this picture without placing any kind of text. In the second line, you inserted a space after the name-field.

Here is a helpful link.

Please note: If you want to use money-fields in if-statements please change the type of the CRM field in the field properties.


Figure 1: Field properties – change type

That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.

Was this helpful?

2 Yes  4 No
Related Articles
  • Introducing the DocumentsCorePack Template Designer Office Add-In (Beta)
  • Ensuring correct time zone display for DateTime fields
  • How to compare a date-fields with the current date 
  • Create a template for XML or plain text
  • E-Invoicing with DocumentsCorePack
  • How to add content from SharePoint to a document
Latest Articles
  • What Happens After You Deploy AttachmentExtractor: Storage & Cost Savings in Dynamics 365
  • Deploying DocumentsCorePack: Setup, Automation, and Real Business Impact in Dynamics365
  • Introducing the DocumentsCorePack Template Designer Office Add-In (Beta)
  • How to Eliminate Excess Storage Costs in Microsoft Dynamics 365 Without Losing Access to Emails and Attachments
  • 3 Ways DocumentsCorePack Transforms Proposal, Quote, and Contract Creation
Popular Articles
  • DocumentsCorePack Template Designer – Getting Started
  • Step-by-Step: How to configure a One-Click-Action
  • Application Access for Dynamics 365
  • How to find your environment’s unique name in Microsoft Dynamics 365
  • How licenses are counted
Top Rated Articles
  • “Undefined”-labels in Chrome and Edge 114 and higher
  • Important information for Dynamics 365 online customers using DocumentsCorePack and/or AttachmentExtractor
  • How to activate the DocumentsCorePack Connector for PowerApps & Microsoft Flow
  • How to insert Condition Fields in DocumentsCorePack Templates designer
  • How licenses are counted
Categories
  • *News and General Infos* 64
  • Webinars 45
  • Template Designer(DCP 196
  • DocumentsCorePack(DCP 258
  • TelephoneIntegration (TI 65
  • AttachmentExtractor (AE 75
  • PowerSearch (PS 50
  • ActivityTools (AT 61
  • SmartBar (SB 54
  • GroupCalendar (GC 47
Our Vision

“We see it as our purpose to provide products that simplify and speed up our customers’ Microsoft Dynamics 365 experience.”

Knowledgebase
LogIn
mscrm-addons.com
  • Products
  • Online Shop
  • Downloads
  • My Account
About Us
  • About Us
  • Case Studies
  • Newsletter
  • Partner Program
  • Contact
Support
  • Support
  • Terms & Conditions
  • Documentation
  • Webinars
  • Legal Documents
  • Impressum
  • © 2022 www.mscrm-addons.com. All Rights Reserved.