Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / Patches in CRM / How To Create Manual Many T...

How To Create Manual Many To Many Relationships In CRM

CRM provide us many type of relationship-

1:N - 1:N relationship refers to the relationship between two entities, in which a single entity record can be associated with multiple related entity records.

For example- One account can be associated with many contacts.

N:1 - N:1 relationship refers to the relationship between two entities in which multiple entity records can be associated with single entity record.

For example- many records of contact entity can be associated with single account Entity.

N:N – N:N relationship refer to the relationship between two entities, it states that, many records of one entity can be related to many records of another entity.

Here we are discussing about the many to many relationships between entities

In CRM, two types of N: N relationships are available:-

1. Native many to many-

This type of relationship exists between two entities and one intersection entity stores identifier for each related record.

Native many to many relationship is created by the System which is utilized by a hidden intersect entity. This entity is created by the CRM platform, where the user provides the names of the related entities. This is a hidden entity therefore it is not available for any customization.

For Example: We have two entities, Book and Author, A book can be written by many authors and many authors can write a single Book.

When we create N:N relationship between these two entities, one intersection entity is also created, let us say Book_Author is a intersect entity.

This entity is created by system, this will store identifiers of both the entities.

We cannot perform any customization in the intersect entity.

2. Manual N:N relationship

To overcome the disadvantages of Native many to many relationship, We have a manual N:N relationship. Here, I am going to show you the ways to create manual many to many relationships between entities in CRM.

For this, we need to follow few steps-

1) First you need to create two custom entities, for example we are going to create two custom entities RC_Order and RC_Product.

For creating entity follow the below path-

Setting ->customization ->Customize the system

Refer the below screen for RC_Order entity Creation :

Entity-creation.jpg

This entity is displayed in Sales and marketing module-

2) After creating entity we need to create few fields, here I have created three new fields-

CustID, Order_Date and RC_ID.

Refer the below image-

second-step.jpg

3) After creating fields for RC_Orderentity , we need to add these fields in EntityForm.

Here I have added all three fields in RC_Order Main form.

Refer the below image-

Third-step.jpg

4) We need to follow same steps for RC_Product Entity, follow this path, for entity creation

Setting ->Customization ->Customize the system

Refer the below image-

Fourth-Step.jpg

This entity is also displayed in Sales and marketing module.

5) After creating the RC_Product entity, we need to create few fields; here I had created four new fields namely: Description, Price, Quantity and RC_PID

Refer the below image-

 Fifth-Step.jpg

6) When you have completed creating the custom fields add these fields in RC_Product Entity Main Form

Refer the below image-

Sixth-Image.jpg

7) Now, we have two custom entities, here we are going to create manual many to many relationship   between RC_Order & RC_Product, to do this we require, one more entity which can behave like an intersect entity. This entity holds the identifier of both entities.

Hence, we need to create one more entity OrderDetails (intersect Entity).

Refer the below image-

Seventh-Image.jpg

It is also visible in sales and marketing module.

8) As, I mentioned in previous steps, this entity holds identifier of RC_Order and RC_Product entity.

So for holding identifier we need to create few fields which can contain related entity data. here I am creating four new fields-

Order, Product, Quantity and OD_ID.

The first field is Order, which can hold RC_Order entity data.

Refer the below image-

 Eighth-Image.jpg

When you create this field you need to select few things-

DataType : Lookup

Target record type- RC_Order

When you select these two value “Relationship name” is added automatically. Next is to save and publish the customization.

9) We need to repeat the same step to create one more field Product for RC_Product entity.

Refer the below image

Ninth-Image.jpg

Same as Order field, we need to select few things-

DataType :Lookup

Target record type- RC_Product

When you select these two value “Relationship name” is added automatically, Next is to save and publish the customization.

10) Repeat the previous step, we need to create OD_ID, and Quantity fields,

For OD _ID creation

Refer the below image-

Tenth-Image.jpg

For Quantity creation-

Refer the below image-

Tenth1-Image.jpg

 

11) Now, We had created 4 fields Order, Product, OD_ID and Quantity, after creating all fields Save and publish the Customization.

Refer the below image-

11th-Image.jpg

12) In this step, we need to add these fields in Entity “Orderdetails” Main Form then save and publish the customization.

Refer the below image

Twelth-Image.jpg

13) In the previous steps, we had created 2different one to many relationships between RC_Order to OrderDetails and RC_Product to OrderDetails using lookup fields. In that case RC_Product and RC_Order entity are connected indirectly with each other.

Refer the below image for more understanding-

RC_5F00_Order.jpg

 14) Now, I am going to show you this relationship behavior with the help of crm records.

For this, we need to create one or more records in RC_Order&RC_Product entity.

Refer the below image for Rc_Order

RC_5F00_Order-New.jpg

Refer the below image for RC_Product-

RC_5F00_Product.jpg

Here, we have 2-2 records in both the entities.

So the question remains, How to relate these records to each other?

To do this, when records are created for OrderDetails entity, we are able to connect RC_Order and RC_Product entity records via relationship.

 OrderDetailsentity.jpg

Refer the below image-

When you create record in OrderDetailsentity,SelectRC_Order from Order lookup field-

RC_5F00_Product-from-Product.jpg

Next step is to select RC_Product from Product lookup field-

After adding all the values, save this record using the save button, now your Orderdetails record will look like this.

Refer the below image-

Orderdetails-record.jpg

In this way, we are able to create manual many to many relationships between entities and now you can do any customizations with intersect entity and it is also available for workflows.

Author Bio: In this tutorial, Microsoft Dynamics CRM Customization team have explained us about creating manual many to many relationships in CRM. If you face any difficulties in the coding part, please leave your comments below, we would be happy to help.

Comments

*This post is locked for comments