• Release History
  • Documentation
  • Back to www.mscrm-addons.com
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
home/Knowledge Base/Template Designer(DCP)/How to use Aggregation properly when creating templates

How to use Aggregation properly when creating templates

1844 views 0 Updated on December 22, 2023

Aggregated fetches are a useful functionality when creating templates. They allow you to aggregate certain data  (e.g., count, create a sum, or calculate the average of revenues, see Aggregation in DocumentsCorePack). Among other use cases, they e.g. allow to create quarterly, yearly, monthly, or daily reports (see How to create an account sales report template).

This article provides you with a step-by-step tutorial on how to define and use aggregation inside your templates. Click here to get a further overview of Aggregation in DocumentsCorePack.

Example: We want to display the invoices associated with an account by showing their count and total.

Step 1: Open Word, navigate to the ❶ www.mscrm-addons.com tab, and click on the ❷ Insert MailMerge fields button. The DocumentsCorePack Question Dialog opens. Click Yes to open the DocumentsCorePack Template Designer.

How to open DocumentsCorePack Template Designer
 Figure 1: How to open DocumentsCorePack Template Designer

Step 2: In the opened Template Designer, select the entity type you want to work on, like ❶ Account in this example. Click the ❷ Additional tab and the ❸ Add Relationship/Entity button.

Adde a relationship
Figure 2: Add a relationship

Step 3: The Configure Fields and Datasource window is shown. Select a relationship in the drop-down menu. In our example, we selected Account > Invoice [customerid]. Check the activate aggregation functionality.

Activate aggregation
Figure 3: Activate aggregation

Step 4: Also, you can set certain aggregation functionalities. The Attribute drop-down menu enables you to select an attribute field, while the Aggregate/Group by drop-down menu provides you with an overview of which aggregation functionalities can be applied to this field.

In this example, we listed the Invoices from accounts and the total amount of them.

Please note: The possible aggregation functionalities depend on the attribute field you select. Click on the OK button to proceed.

Set the aggregation functionality
Figure 4: Set the aggregation functionality

Step 5: Insert the newly resolved relationship

Once the fetch is configured, we can go ahead and add the fields to our template. In our example, we will create a simple 3×2 table using Word’s table creator. Now enter the fields for the total number of the invoices and the total amount of the invoices to the table.

As shown in Figure 5, the relationship consists of two parts: The name of the field and in brackets the aggregation functionality that has been applied to the relationship.

1 Invoice (count)
2 Total Amount (sum)

Insert resolved relationships
Figure 5: Insert resolved relationships

Step 6: This is an example of a template that displays the number of invoices connected to an account and their total.

Account with connected invoices and their total
Figure 6: Account with connected invoices and their total

Step 7: Once saved, we can run a test. If you have not merged and/or tested a template before, please have a look at this article. As can be seen in Figure 7. We get a nice table row showing the aggregated count and sum of all invoices related to our account.

Result
Figure 7: Result

If you want to learn more about creating an account sales report follow this link.

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

Was this helpful?

Yes  1 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
  • Using MS Word field codes in DocumentsCorePack templates
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.