Friday, March 24, 2023

Microsoft Dynamics 365 CRM - Create and edit entity relationships (Classic UI)

Create and edit entity relationships

Entity relationships define how records can be related to each other in the database. At the simplest level, adding a lookup field to an entity creates a new 1: N (one-to-many) relationship between the two entities and lets you put that lookup field in a form. With the lookup field, users can associate multiple “child” records of that entity to a single “parent” entity record.

Types of entity relationships:

Relationship Type

Description

1:N (One-to-Many)

An entity relationship where one entity record for the Primary Entity can be associated to many other Related Entity records because of a lookup field on the related entity.
When viewing a primary entity record you can see a list of the related entity records that are associated with it.
For example, an opportunity without a potential customer wouldn’t be very useful.

N:N (Many-to-Many)

An entity relationship that depends on a special Relationship Entity, sometimes called an Intersect entity, so that many records of one entity can be related to many records of another entity.
When viewing records of either entity in a N:N relationship you can see a list of any records of the other entity that are related to it.
The Opportunity entity also has a N:N relationship with the Competitor entity. This allows for multiple competitors to be added to the opportunity.

The N:1 (many-to-one) relationship type exists in the solution explorer user interface because the solution explorer shows you a view grouped by entities. 1:N relationships actually exist between entities and refer to each entity as either a Primary Entity or Related Entity.

 

Create and edit 1:N relationships

The easiest way to create a 1:N relationship is to create a new lookup field for an entity. This allows you to set the common field values for the lookup field as well as two additional options when you set the Type to Lookup. Those additional fields are Target Record Type and Relationship Name. Target Record Type selects the Primary Entity in the 1:N relationship.

If you create a lookup field for an entity Opportunity and Target Record Type is Account then in Opportunity to Account it will be N:1 relationship and Account to Opportunity it will be 1:N relationship.

And if you create a 1:N relationship from an entity node system will create one lookup type field in Related Entity.

1.      Navigate to Microsoft Dynamics 365 > Settings > Solutions click on your work solution and from solution explorer Under Components, expand Entities, and then expand the entity you want.

2.      Click on 1:N Relationships.

3.      To create a new relationship, on the command bar, click New 1-to-Many Relationship.

- OR -

To edit an existing relationship, double-click or tap any existing relationship.

Note: In this screen custom entity Country is used. Refer here to create custom entity.

 

4.      For a new relationship, in the Relationship Definition section, in the Related Entity list, select the entity to be related.

5.      Select whether this will be searchable to not.

6.      In the Lookup Field section, specify a value for the Display Name field.

7.      In the Field Requirement list, choose an option to specify data requirements for the field prior to saving a record.

8.      In the Relationship Behavior section, in the Type of Behavior list. Refer here for more details.

9.      Click Save and Close to close the Relationship form.

10.   Publish the customization.

 

Create and edit N:N (many-to-many) relationships

1:N entity relationships establish a hierarchy between records. With N:N (many-to-many) relationships there is no explicit hierarchy. There are no lookup fields or behaviors to configure.

With N:N relationships a special entity is created called a Relationship (or Intersect) entity.

Create or edit N-N relationships between entities

1.      Navigate to Microsoft Dynamics 365 > Settings > Solutions click on your work solution and from solution explorer Under Components, expand Entities, and then expand the entity you want.

2.      Click on N:N Relationships.

3.      To create a new relationship, on the command bar, click New Many-to-Many Relationship.

- OR -

To edit an existing relationship, double-click or tap any existing relationship.



4.      For a new relationship, in the Current Entity section, in the Display Option list, choose one of the following options:

·        Do Not Display: The other entity will not display an associated view for the current entity.

·        Use Custom Label: This label will be used for the associated view created for the other entity. Be sure to enter a corresponding value in the Custom Label field.

·        Use Plural Name: This will use the plural name of the current entity for the associated view.

5.      In the Other Entity section, select the other entity from the Entity Name list.

6.      In the Relationship Definition section, confirm the Name and the Relationship Entity Name.

These values must be unique among N:N relationships.

7.      Click Save and Close to close the N:N Relationship form.

8.      Publish the customization when complete.

 

No comments:

Post a Comment