Microsoft Dynamics CRM Connections provide a flexible way to connect and describe the relationships between two records.
For example, from a Contact record we will create a Connection to another Contact record for a referral. This is accomplished by opening the Contact record, then clicking on the Connection link, then clicking Connect from the ribbon. You can then connect to another record or have another record connect to the originating record.
After clicking on the To Another link, a popup window is displayed where you can specify the record that you will be connecting to. You can also specify the As this role which allows you to describe the relationship between the related record.
If you expand the Details section you can see the originating record and its role.
After the record is saved, CRM creates two entries in the Connection table in the database. Each entry allows you to search for the related record from the originating record or the related record. If you inspect the Connection table in the database you will notice that there are Record1 and Record2 fields which store the primary keys of the related records (in this case the Contact records) and Record1Role and Record2Role fields which stores the primary keys of the Connection Role. These are the fields that are used to find how a record is connected to another record.
But which record points to Record1 or Record2? Because CRM creates two entries, you can choose either one. In the example above you can say that John Doe points to Record1Id and Jane Doe points to Record2Id or vice versa. You can determine which to use by the way you start your search for the related record.
For example, in a SQL or Fetch XML query, if you wanted to retrieve fields from the related Jane Doe record you would start from the Contact record of John Doe and join to the Connection record where the ContactId equals Record1Id and then join back to the Contact record where the Connection’s Record2Id equals the ContactId of Jane Doe.
The Connection Role allows you to filter further. If John Doe is connected to various records with different roles you can use the Record1RoleId or Record2RoleId to only retrieve the type of relationship you are looking for (You again determine which Record1Role or Record2Role to use by the direction that you chose to start your connection).
In the example above, John Doe is connected to Jane Doe where Jane Doe has the role of Referral. From our SQL/Fetch XML example, if we wanted to retrieve only related referral records we would set the Record2RoleId to the Referral Id of the connection role.
At PowerObjects, CRM education is one of the four building block to CRM success. Please comment and let us know if this post has been helpful. If you have other topic areas you would like us to focus on in future posts, let us know as well.
Latest posts by JoeCRM (see all)
- How to Assign a Territory to a Lead in Dynamics CRM - May 17, 2013
- Out of the Box Report: Dynamics CRM User Summary - May 16, 2013
- Dynamics CRM / XRM Integration with GIS and PowerMap - May 15, 2013