Here we start 1:N & N:1 & custom 1:N relationships
In a 1:N relationship, a primary record can be associated with zero or more related records, and the related records can be associated with one primary record.
We create a custom 1:N relationship in Microsoft Dynamics CRM 2011 from the primary entity by specifying the related entity type. We can also create a custom N:1 relationship from the related entity by specifying the primary entity type. So, the 1:N and N:1 relationships are created from a different starting point, but are
otherwise the same. We can also create custom N:1 relationships by creating a lookup field on a related entity.
For example, in Microsoft Dynamics CRM 2011, an account can have many contacts associated with it. Each contact can have a parent account. From the point of view of the account, this is a 1:N relationship with contacts, and from the point of view of the contact, this is a N:1 relationship with accounts.
Creating a custom 1:N relationship
To create a custom 1: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 1:N Relationships area.
5. In the grid toolbar, click on New 1:N Relationship.
6. In the New Relationship pop-up window, provide the following information:
°° Primary Entity: The primary entity from which you want to create a 1:N relationship, for example, Account
°° Related Entity: The entity to which you want to create a 1:N relationship, for example, Policy
Note: If you are creating a 1:N relationship, the Primary Entity field is already selected and is read-only. You can specify the related entity. If you are creating a N:1 relationship, the Related Entity field is already selected and is read-only. You can select the primary entity.
°° Name (in Relationship Definition): Schema name of the relationship, for example, packt_account_packt_policy is the default name for a custom 1:N relationship between the account and packt_account entities
°° Display Name: The name of the lookup field
°° Name (in Lookup Field): Name of the lookup field displayed on the primary record, for example, Policy Holder.
°° Requirement Level: The requirement level for the lookup field (following options are available for this field):
No Constraint: It is optional for related records to have a primary record
Business Required: It is mandatory for related records to have a primary record
Business Recommended: It is suggested that related records should have a primary record
°° Description: A description for the lookup field
°° Display Option: Specifies whether the related records are displayed from the primary record (the following options are available for this field):
Use Plural Name: The related records are displayed in an area on the primary record using plural name of the related entity as the area label
Use Custom Label: The related records are displayed in an area on the primary record using a custom label for the area
Do Not Display: The related records are not displayed on the primary record
Custom Label: The custom label that is used when Display Option is set to Use Custom Label
°° Display Area: The area group on the primary record where the related records are displayed
°° Display Order: The sort order of the related records area on the primary record
°° Type of Behavior: The relationship behavior between the two entities when certain actions are applied to a primary record (see the Relationship behaviors section discussed later in this chapter) for further details
7. Click on Save and Close.