Office Open XML has been invented to enable the creation of very complex templates that would normally require the use of macros. This article contains a step-by-step description about how to create such a template.
As for demonstration purpose, we decided to create a so called quote-with-grouping-template in this example, because it is most likely used by Microsoft Dynamics CRM users.
(Quote-with-grouping means that the quote-products are grouped by the value of a specific CRM-attribute, for example, subject.)
First, we need to create the basic layout of the template. Clicking on the
[Insert MailMerge Fields]-menu button in the www.mscrm-addons.com command bar will open the DocumentsCorePack Template Designer.
Now, to create the basic layout for, e.g. a quote-with-grouping-template, we must select the type Quote in the Type-Selector-Dropdown Menu. Each template is based on a specific entity.
Now that we have selected an entity, we need to insert fields to our template. To do so, we set the cursor at the position where we would like to insert a certain field. Then, we double click the fieldname. You could as well insert it via the [Insert field]-button. For more information on the [Insert field]-button, have a look at this article.
Figure 2: Template Designer – Insert fields
Once you have inserted all the fields you would like to insert, your template could look like this:
The next step is to resolve the quote-quote product relationship. To do so, we need to click on the Additional-tab in the DocumentsCorePack Template Designer. The Additional section allows to resolve any relation/entity within CRM and brings up a list of all attributes from the related entities so that they can be used within the document too.
Here, we click on the [Add Relationship/Entity]-button in order to add a new relationship.
Figure 4: Template Designer – Additional tab
We use the Configure fields and data source – dialog to resolve the fields, tables and relationships we need for our document.
In our example we must select Quote -> Quote Product [quoteid]. As a result, the available fields of this relationship are displayed in the Attributes field of the Configure fields and data source dialog.
As soon as we click on the [OK]-button, all the selected fields will be related to the Quote Product table. Please note: Only the fields checked in the Attributes field will later be visible in the DocumentsCorePack Template Designer.
The procedure of inserting a table of items is completely automated, so we just need to set the curser to the position where we want to add the table and double click on one of the fields that we have previously added to the table. As soon as we do so, a dialog (see Figure 8) appears.
Within this dialog, you can select between three possibilities how the fields should be inserted to the table.
In our example, we want to insert a new table with a header and a footer. So we select the corresponding options and click on the [OK]-button.
As a result, the table will be inserted at the determined position:
Once we have inserted the table, we can add fields like quantity, product-name or even a table header including column-names with the formatting options available in the www.mscrm-addons.com - tab.
Figure 10: mscrm-addons.com-tab (Rows and Columns)
With a click on the Rows and Columns – Dropdown, you get the possibility to split or merge the columns, to insert a right or left column, to delete a row or a table and to add a header or a footer row.
Figure 11: Column customization
Please note: It is of upmost importance to insert the header, as well as the footer, exclusively via the www.mscrm-addons.com – tab in the command bar! Do not enter them via Microsoft Word!
After saving the document and selecting our CRM-data we can see the result with the replaced fields at the top, the line item table including the sum in the middle and the bank-details at the bottom.
Figure 12: DocumentsCorePack template – Result
That is how you create a DocumentsCorePack template!
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to firstname.lastname@example.org.