DocumentsCorePack is an add-on for document generation and management based on Dynamics 365 data. It uses XML like the out of the box Word Templates but has more functionality such as combining with workflows to produce documents automatically, sending documents via email automatically, producing pdfs and saving documents to SharePoint. In this blog, I will share some tips on using some of the more advanced functionality.
By default, when you select the record type you want the document generated from, all the fields on that record and all the fields from any look up on that record are loaded so you can use them in the template. DCP also allows template designers to define Additional Relationships to pull other data into the template – this can be based on any Dynamics 365 relationship to the record type you are using and records related to those records and so on. This can be used to filter records based on values of another record. For example, you need to do a new invoice template that groups and totals sections based on an attribute of the product.
TIP: When you add the filtering relationship, don’t forget to change the Type of Relationship to Inner. This defaults to Outer which doesn‘t help as the filter is not applied.
When you create an Additional Relationship, you can give it a name but this name doesn’t show on the merged fields in the template. So, naming the relationship doesn’t help if you need to go back and change it or check how it has been set up.
TIP: Click on the DCP Ribbon Field Properties function – this will show the name of the Table shown in the Additional Relationships drop down.
DCP can aggregate data when you create an Additional Relationship. This can come in handy if, for example, you wanted to add a statement to the invoice based on what is outstanding as you can use this total in combination with a Word conditional statement.
TIP: Use the Result tab on the Additional Relationship to check the format of the aggregated result because the Word Conditional Statement won’t work if the Criteria is in a different format to the result.
There are 2 options to match the formatting:
1. You can format the Criteria in the Conditional Statement to match the calculated result
2. You can change the format of the calculated result to ‘ovalue’ by clicking on the Field Properties and selecting use Internal value
Hope these tips help!