• Release History
  • Documentation
  • Back to www.mscrm-addons.com
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
home/Knowledge Base/Template Designer(DCP)/Using MS Word field codes in DocumentsCorePack templates

Using MS Word field codes in DocumentsCorePack templates

552 views 0 Updated on November 5, 2024

DocumentsCorePack templates can utilize Microsoft Word’s many formatting tools and options.  Word’s own field codes are no exception.  In tandem with the Template Designer’s fields, such fields can add another dynamic layer to your documents. 

This article describes how to use common field codes in combination with Dynamics 365 data. 

Note: Delimiters for Word formulas and methods will vary based on culture.  For English-based systems, the delimiter character is the comma (“,”), whereas for German-based systems, the delimiter character is the semicolon (“;”). Please keep this in mind when constructing your own formulas.  The examples in this article are all based on an English system. 

Table of Contents

  • The “IF” field
  • The “DocProperty” field
  • The “= (Formula)” field
  • The “Set” and “Ref” fields 
  • The “SEQ” field

The “IF” field

The IF field inserts a specified value based on comparing two values allowing content to be conditionally added to documents.  The field code has the following syntax: 

{ IF Expression1 Operator Expression2 TrueText FalseText} 

Fields from Dataverse can be inserted in place of the expressions or the true/false text to produce a condition based on the corresponding values. 

For a detailed description and example, please see this article. 

The “DocProperty” field

The DocProperty field will insert a specified value from the document’s Properties.  The field code has the following syntax: 

{ DOCPROPERTY “Name” } 

In combination with dynamic document properties, Dataverse values can be written to the properties of a generated document, allowing the DocProperty field to insert the dynamic value into the document itself. 

Example: 

We can set the Company property of the document to be the name of an account’s record by adding a text-based dynamic document property.  This is shown below: 

Adding a text-based dynamic document property
Figure 1: Adding a text-based dynamic document property

Then, after adding the DocProperty field code for the Company property in the document… 

The DocProperty field code, before merging
Figure 2: The DocProperty field code, before merging

…the dynamic value will be displayed upon merging the template: 

The DocProperty field code, after merging
Figure 3: The DocProperty field code, after merging

The “= (Formula)” field

The Formula field performs a calculation based on a given mathematical formula.  Values from Dataverse can be inserted via the Template Designer within Formula fields to generate a dynamic result. 

Example: 

We can calculate and apply tax to the total amount of a quote by using a formula field.  After adding the field and applying the necessary formatting, we can add our Dataverse fields along with a fixed value for our tax. 

The formula prior to merging
Figure 4: The formula prior to merging

The corresponding values will appear in our formula after generating the document.  The formula will calculate the result based upon these values. 

The formula after the merge
Figure 5a: The formula after the merge
The resulting value
Figure 5b: The resulting value

Note: DocumentsCorePack’s calculated fields can achieve similar results. 

The “Set” and “Ref” fields

The Set and Ref fields assign and insert information in the document based on a given bookmark, respectively.  More specifically, the Set field “sets” data to a bookmark, while the Ref field “references” the information from the bookmark once placed in the document. 

Dataverse fields can be used in combination with Set and Ref fields.  By inserting them into the former, they can be later used by the latter. 

Example: 

When creating a thank you message that includes the price and number of licenses purchased, we can set our fields from Dynamics 365 using the Set field in order to reference them later. 

Assigning and reusing our Dataverse fields with Set and Ref
Figure 6: Assigning and reusing our Dataverse fields with Set and Ref

After merging the template, the Dataverse fields will pull the data from our record. 

The field codes with the values from Dataverse displayed
Figure 7: The field codes with the values from Dataverse displayed

The result will display the corresponding information in our thank you message. 

The resulting message
Figure 8: The resulting message

(For another example that uses the Set field, please see our article on ordinals) 

The “SEQ” field

The SEQ field numbers items in a document sequentially. If used in tandem with a dynamic table, it can be used to number the table’s line items.

Example:

If we create a simple invoice table, we can position the fields in such a way where the Seq field can be placed on the right hand side.

When the template is merged, the resulting document will display the item numbers in sequence.

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

Tags:field functionsfield codesms wordword fields

Was this helpful?

Yes  No
Related Articles
  • 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
  • Step-by-Step: How to create a label template
Latest Articles
  • DocumentsCorePack: Best practices for Dynamics 365 on-premises to online migration projects
  • Multilingual Support in DocumentsCorePack
  • Recap: ColorCloud 2025
  • Configure DocumentsCorePack within custom pages
  • AI-Powered Document Generation with Copilot in Sales
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 licenses are counted
  • How to insert Condition Fields in DocumentsCorePack Templates designer
Categories
  • *News and General Infos* 62
  • Webinars 44
  • Template Designer(DCP 196
  • DocumentsCorePack(DCP 250
  • TelephoneIntegration (TI 65
  • AttachmentExtractor (AE 72
  • 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.