This article outlines how to work with relationships in the DocumentsCorePack (DCP) Template Designer to map data from records related to your starting table (entity).
The following three step-by-step tutorials will teach you how to create and manage complex relationships with the DCP Template Designer Additional tab. Essentially, relations can be solved for 1:N (1:many) and N:N (many:many) relationships. All custom entities, as well as system entities, are supported.
Step-by-Step Video:
Tutorial 1: How to add a predefined relationship
Predefined relationships are helpful when you create a common template, for example, a quote template. With a predefined relationship, you do not have to manually create a new template for each quote.
Step 1: Create a new template
For further information on how to create a template, please read this article.
Step 2: Navigate to the “Additional” tab in the Template Designer
Next, open the Additional tab. It has been designed to manage additional relationships.
Step 3: Add a relationship/entity
Click on the Add Relationship/Entity button to open the relationship designer (see tutorial 2), or click on the drop-down arrow to expand a menu with predefined relationships.
The highlighted area in Figure 3 shows all predefined relationships. DocumentsCorePack already has a variety of different predefined relationships for standard CRM entities ready for you (for example, All Contacts of an Account, Quote Products of a Quote, etc). They facilitate the creation of templates. Simply click on the predefined relationship to add it. The related fields will then be visible in the Template Designer TreeView.
Tutorial 2: How to add a relationship from scratch
When you are dealing with more complex relationships, it can be helpful to create a relationship from scratch.
Step 1: Create a template and insert fields
For further information on how to insert fields, read this article. As you see below, we have inserted the following fields: <<accountid>> and <<name>>
Step 2: Add a new relationship
Next, go to the Additional tab and open the Add Relationship/Entity drop-down menu. Then, select Add New Relationship.
The Configure Fields and Datasource dialog will open. Select a relationship you would like to insert ❶ and add attributes by checking the boxes next to the attributes ❷. In the example below, we have chosen the relationship Account > Activity [regardingobjectid] and added the following attributes: Activity, Actual End, Actual Start, and Due Date.
The chosen attributes of the entity are now also visible in the Additional tab of the Template Designer. From here, you can insert any of the fields into the document. However, there are usually more complex relationships needed. That is why you may expand the complexity of the relationship by adding more levels.
Step 3: Add further relationships
If you would like to add further relationships, click Edit in the Additional tab.
This action opens the Configure Fields and Datasource dialog again, providing you with the former established relationship. Select ❶ Add and add another relationship ❷ here. In the example below, we added Activity [activityid] -> Attachment [objected] and the entities ❸ Attachment Number, Entity, File Name, Subject.
As you can see, the resolved entities are now also visible in the Additional tab of the Template Designer. From here, you can insert any of the fields into the document.
Please note: You may repeat these steps as often as you would like to in order to enhance the complexity of your relationships.
Tutorial 3: How to create a relation to a separate entity
The creation of a relation to a separate entity follows the same rules as the creation of an entity from scratch, with one exception. In order to create a relation to a separate entity, follow the steps in Tutorial 2 carefully, but make sure that you change the following parameter when you select a new relationship:
Instead of checking Relationships, check Separate Entities ❶ in the Select existing Relation section. The main difference is that you will now be provided with separate entities ❷ instead of relationships.
Additional Filtering
The most common additional step when adding a relationship is adding additional filters to limit returned results. For example, if you only want to see active records, you would add an additional filter for that. How to create or modify additional filters is described here.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.