Entity Relationships in Dynamics 365

1 Comment

When creating relationships between entities in Dynamics 365, you can decide how the entities are related together and additional rules. We will go through setting this up in Dynamics 365.

Let’s say you have a scenario where you have 2 custom entities, “My Orders” and “My Order Lines”. The My Order Lines entity is the child of My Orders. So, one “Order” can have multiple “Lines”, but Lines cannot have multiple orders. So, this will be a 1:N relationship for Orders:Lines.

To add a relationship, you can either add the relationship from either entity. We will go to the My Orders entity and select 1:N Relationships. Note some relationships already exist:

Select “New”.

You will see the relationship options. Select the My Order Line related entity, then enter required fields, some of which will default and you can overwrite:

Note the Relationship Behavior section.

Selecting Parental, Referential or Referential, Restrict Delete will set the other fields to ready only and therefore non-configurable. Each behavior has pre-defined rules.

Note the options for Parental:

And Referential:

And Referential, Restrict Delete:

And Configure Cascading:

Selecting Configurable Cascading will allow you change the configuration of most of the options, including: Assign, Share, Unshare, Reparent and Delete. Which means, when the parent record is assigned, shared, unshared, reparented or deleted, the system will perform the set cascade rules you set.

Merge and Rollup View are still not configurable and are set to Cascade None:

Note the options available depending on the action:

  • Cascade All – this means the action is cascaded, i.e. if an action happens on the parent, do the same thing to the child records
  • Cascade Active – if an action happens, perform it on active records
  • Cascade User-Owned – perform the same action on records owned by the same user
  • Cascade None – don’t do anything

For Delete, we have:

  • Cascade All – perform same delete action on record
  • Remove Link – remove link but don’t delete the record
  • Restrict – do not allow deletion

For our example, we will set the behavior to “Referential” and publish the customizations.

Note the relationship appears as a N:1 on the My Order Lines entity:

For our test, we will create a new My Order called Test 1:

Now enter a My Order Line:

Now, let’s delete our order. In deleting the order, the line is not deleted, as we can see from Advanced Find:

As we are set up with referential behavior, the delete option is to remove the link between the Order and the Line.

Now let’s say we want to delete a record in this scenario. We will set the behavior to Parental. Save and Publish.

Now, when we create a new My Order and My Line:

After deleting the order, the line is also deleted:

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

One Response to Entity Relationships in Dynamics 365

  1. Hi Carl
    I am struggling to get some Email Activities linked to an Opportunity to be displayed against the related Contact and Lead – can see them against related Company with no issue – have checked the relationship in Contact and Lead and all looks ok – only thing is not able to reset the Rollup and relationship set to Parental. – all other options are set to Cascade All.

    Need to get this working any advice would be appreciated

Leave a Reply

Your email address will not be published. Required fields are marked *