Relationships in Dynamics CRM 2011

Roshan Mehta, 21 June 2011

Microsoft Dynamics CRM is designed to record and track the relationships between various parts of an organization. There are a number of out-of-the-box relationships which we can create such as an Employer/Employee relationship by storing multiple Contacts within an Account.

Relationships in Dynamics CRM 2011*

Types of Relationships

There are three main types of relationships we can create in Dynamics CRM: One to Many (for example “One Employer has many Employees”), Many to Many (for example “Many Students can attend Many Courses”), and Many to One (for example “Many Employees are employed by One Employer”). The type of relationship you choose depends on internal rules within your business.

Parental vs Referential Relationships

In a Parental Relationship, anything done to the parent record is also done to related records. For example, if an Account is deleted all related Contacts for that Account are also deleted.

In a Referential Relationship, actions performed on the parent record do not affect related records. The link between the parent and related records is simply removed.

When you have a One to Many relationship where a custom entity is the primary entity and a system entity is the related entity, the relationship type can only be referential. For example, if you have a custom entity called “Office” which has many Contacts and you delete the Office record, the related Contacts will not be deleted. The link between the Office and its Contacts will be removed.

Native or Manual?

There are two types of Many to Many relationships: Native and Manual. The main difference between the two is that a when you create a Native Many to Many relationship, an intersect entity is automatically created for you. For example, when you create a new Many to Many relationship between a “Course” entity and the “Contact” entity, an intersect entity will be created which has links to both the Course and Contact records. This intersect entity cannot be customized and is not available for use within workflows.

A Manual Many to Many relationship is actually two One to Many relationships. In this case, you actually create the intersect entity yourself. For example, to create a Manual Many to Many relationship between a “Course” and “Contact” entity:

1. Create a new “Course Attendee” entity in CRM.
2. Create a new One to Many Relationship from “Course” to “Course Attendee”.
3. Create a new One to Many Relationship from “Contact” to “Course Attendee”.

The advantage of a Manual Many to Many relationship is that we can customize the intersect entity to track attendance information which can then be available within workflows. For example, we can an Attended and Date Attended field to the “Course Attendee” entity so we can track if a particular Contact attended a Course. If the Course spans over multiple time periods, we can also track the date that the Contact attended the Course.

Self-Referential Relationships

Self-Referential relationships allow you to create complex relationships between two records of the same entity type. For example, you might want to link a User to another User so you can easily track employee hierarchies in CRM. However, you cannot link a record to itself.

When defining relationships within your organization, it’s important to understand the types of relationships to use. In my next post, I will cover cascading rules in Microsoft Dynamics CRM.

 *http://www.signalpatternslabs.com/wp-content/uploads/2008/10/83112718_47.jpg