Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Microsoft Dynamics CRM Connections and How to Search for Related Records

Post Author: Joe D365 |

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.

microsoft dynamics CRM connections

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.

CRM connections

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.

Happy CRM’ing

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

PowerObjects Recommends