Here we start Native N:N & manual N:N relationship.
In an N:N relationship (also called a many-to-many relationship), a record of one entity can be associated with zero or more records of a second entity, and records of the second entity can be associated with zero or more records of the first entity.
Native and manual N:N relationship types
When an N:N relationship exists between two entities, an intersection entity stores the identifiers of each related record.
The following diagram shows a policy, policy claim, and claim entities. The policy and claim entities have an N:N relationship. A policy can have many claims and a claim can be against many policies. The policy claim entity is the intersection entity that is used to store the identifier of each related policy and claim.
There are many scenarios where native N:N relationships will meet our requirements. However, in our example, let’s say we need to store the value of each policy claim because the total amount of the claim might be split against several different policies.
The native N:N policy claim intersection entity is hidden and cannot be customized, so we cannot create a custom attribute on the policy claim entity.
Manual N:N relationships rely on you to create a custom intersection entity with two 1:N relationships that together act as an N:N relationship. Just like any other custom entity, we can see a manual intersection entity in the CRM user interface, we can customize it, and we can interact with it programmatically.
So in our example, instead of creating a native N:N relationship between the policy and claim entities we could create a policy claim entity with the 1:N relationships to the policy and claim entities. Now, we can customize the policy claim entity by creating a policy claim amount field, and any other fields such as the date that the
claim became associated with the policy, the status of the policy claim, and so on.
Creating a native N:N relationship
To create a native N:N relationship, follow these steps:
1. In the navigation pane, click on Settings.
2. In the Customization group, click on Customizations and then click on Customize the System to open the default solution.
3. In the left-hand navigation area of the solution, expand the Entities component and then expand the appropriate entity.
4. Click on the N:N Relationships area.
5. In the grid toolbar, click on New N:N Relationship.
6. In the New Relationship pop-up window, under the Other Entity section,provide the entity name of the other entity, with which you want to create the N:N relationship, in the Entity Name field.
7. For each entity, provide the following information in the Current Entity field:
°° Display Option: This field specifies whether the other entity records are displayed from the current entity record or not. The following options are availabel for this field:
Use Plural Name: The other entity records are displayed in an area on the current entity record by using plural name of the other entity as the area label.
Use Custom Label: The other entity records are displayed inan area on the current entity record by using a custom label for the area.
Do Not Display: The other entity records are not displayed on the current entity record.
Custom Label: This is the custom label used when the Display Option field is set to Use Custom Label.
Display Area: This is the area group on the primary record where the related records are displayed.
°° Display Order: This is the sort order of the related records area on the primary record.
8. In the Relationship Definition section, provide the following information:
°° Name: Schema name of the relationship
°° Relationship Entity Name: The name of the hidden intersect entity
9. Click on Save and Close.