Let’s talk about Dynamics CRM Entity Relationship behavior! There are several behaviors in Dynamics CRM that we can apply to fit our requirements. With this blog post, I hope we can learn together about those options.

But first, we need to understand the entity relationship. When we link (create a lookup) from one entity to another entity, by default CRM will create an entity-relationship (1-to-N, N-to-1, or N-to-N). We can specify from simple behavior how the changes on the parent will affect the children such as referential, parental, and some advanced behaviors to handling: deletion, assigning, sharing-unsharing, and reparent.
Referential Behavior

By default, when we create a lookup, CRM will set the behavior as Type of behavior: Referential and Delete: Remove Link. When the deletion happens to the parent, the children will not be deleted and only will set lookup as empty (null).

When we set the behavior as Type of behavior: Referential and Delete: Restrict. When the deletion happens to the parent and the record got children, it will throw an error “The record cannot be deleted because it is associated with another record.“.

Parental Behavior

When we set the behavior as Type of behavior: Parental and when The parent record is deleted, it will delete the Children records.
Custom Behavior

In the custom behavior, we can specify specific behavior in 5 actions:
1) Delete

- Cascade All > when the parent record is deleted, all the children will be deleted as well.
- Remove Link > when the parent record is deleted, all the children’s lookup will be set as null.
- Restrict > the deletion of the parent will be blocked if the record having children record.
2) Assign

An action to change the ownership of the record to another user/team. You can learn more about this action in the AssignRequest message. Meaning in this action, when the parent record is assigned to another user/team, the children’s records will be assign also.
- Cascade All > when the parent record is assigned to another user/team, all the children will be assigned also.
- Cascade Active > only the children records that the status is active will be assigned.
- Cascade User-Owned > only the children records which own by the user will be assigned.
- Cascade None > no children will be assigned if the parent is assigned to another user/team.
3) Share/Unshare

An action to give access to the record to another user/team. You can learn more about this action in this documentation if you want to do it programmatically. Share action will give them access to the record using the GrantAccessRequest message. While to unshare, you can use the RevokeAccessRequest message.
- Cascade All > when the parent record is shared with another user/team, all the children will be shared also.
- Cascade Active > only the children records that the status is active will be shared.
- Cascade User-Owned > only the children records which own by the user will be shared.
- Cascade None > no children will be shared if the parent is shared with another user/team.
4) Reparent
An action when we set a lookup (when on create or update message). There is a blog post from the crmtipoftheday that you can check to learn more about this.
- Cascade All > when the value of the lookup record is switched with another record, all the children can be accessible.
- Cascade Active > only the children records that the status is active will be accessible.
- Cascade User-Owned > only the children records which own by the user will be accessible.
- Cascade None > no children will be accessible if the reparent occurred.
Conclusion?
You must at least understand about what the behavior that we can apply when we create a lookup. Not just relying on the default behavior, we can apply this knowledge to achieve simplicity in our application depends on your requirement of course!
One thought on “Dynamics CRM Entity Relationship Behavior Explained”