Microsoft Dynamics® CRM Training
An error occurred while loading the video. Please try again.
An integral part of Microsoft Dynamics CRM is the ability to relate records to one another. This is called a relationship. One type of relationships is one-to-many, or 1:N. An example would be the relationship between Contacts and Opportunities. A single Contact record can be related to many Opportunity records.
Some scenarios require many-to-many relationships, or N:N. In this lesson, I’ll create an N:N relationship for a custom entity and the Contact entity.
In this scenario, my organization runs a fitness gym, and the gym hosts numerous sports leagues such as basketball and softball. Members of my gym can sign up for as many leagues as they want. Therefore, I need the ability to associate a Contact with multiple leagues. I also want a league to have the ability to be associated with multiple Contacts.
I have already created the custom entity called Sports League, which I’ve placed in the Workplace module. When I open the “Basketball” record, you see that it is very bare bones; I only have a Name and Owner field. To create the relationship, I need to customize the entity. I click the Customize tab of the ribbon, and then click Customize Entity.
The Solution window for the Default Solution opens. In the Sports League entity I will click N:N Relationships, then click New Many-to-Many Relationship in the toolbar. A Relationship record opens. In the Current Entity section, I want to make sure that Sports League is selected. Notice that I can choose how to display this relationship and where to display it. Instead, I will add it to the form manually later.
In the Other Entity section, for the Entity Name field, I will choose “Contact”. I will then verify that this section is configured so that it does not display in the Contact entity. The relationship is configured, so I can click Save and Close in the ribbon. Back in the Default Solution, I will edit the form before I publish the entity. I click Forms and then open the main form.
To add the associated Contacts to the form, I have to click Navigation in the ribbon. In the Relationship Explorer on the right, I now see “Contacts”. I can drag it to a desired location in the navigation pane. I then Save and Publish the entity. When I close out of the Form Editor and the Default Solution, I reopen the Basketball record.
The Contacts relationship is now present in the navigation pane. When I click it, I see a grid view and I can click Add Existing Contact in the ribbon. Now multiple Contact records can be associated with this league.
For more tips, tricks, and tutorials, please refer to the Success Portal or our xRM.com blog.