Home > CRM 2011 > Multiple relationships between 2 entities

Multiple relationships between 2 entities

What if I have multiple relationships between my entities, how CRM handles multiple “Relationship Behaviors” (i.e., for example Parental & Referential)

Let’s consider this scenario,

  • I have 2 custom entities “Customer” & “Bike” and my requirement is a customer should possess multiple bikes
  • I created a 1:N relationship with “Type Of Behavior = Parental” between “Customer” & “Bike”
Parental Behavior

Parental Behavior

  • Since the relationship behavior is “Parental”
    • If I Delete a “Customer” record, all associated “Bikes” get deleted (i.e., Because of ‘Cascade All’ Delete)
    • If I Assign a “Customer” to user X, all associated “Bikes” owner change to user X (i.e., ‘Cascade All’ Assign)

Now, just to my curiosity

  • I created another 1:N relationship with “Type Of Behavior = Referential Restrict Delete” between “Customer” & “Bike”
Referential Restrict Behavior

Referential Restrict Behavior

  • Since relationship behavior is “Referential Restrict Delete”
    • I cannot delete a “Customer” record, If its associated with “Bikes” records (i.e., Because of ‘Restrict’ Delete)
    • If I Assign a “Customer” to user X, all associated “Bikes” owner does not change (i.e., ‘Cascade None’ Assign)

Now if you see the “1:N relationships” of “Customer“, it will have 2 relationships as below

Multiple Relationships

Multiple Relationships

Let’s try Delete & Assign scenarios and see how CRM application handles Parental & Referential behaviors

Delete Scenario

  • I have a customer “Test” with 2 bikes
  • Now, lets try to delete customer “Test” and see which of two behaviors (i.e., “Parental” or “Referential Restrict Delete”) applies
  • Here I got “Restrict Delete” validation message, so “Referential Restrict Delete” behavior take precedence
Could not delete

Could not delete

Assign Scenario

  • When I change the ownership of “Test”
  • All my “Bikes” ownership changed to new owner of customer “Test”, so “Parental” behavior take precedence

Conclusion

  • In these scenarios, CRM always unions, so in our scenario when I have “Parental” & “Referential Restrict Delete”
    • In case of Delete “Cascade All” union “Restrict”, so it restricted the delete
    • In case of Assign “Cascade All” union “Cascade None” = Cascade All, so all associated records ownership also change

🙂

Advertisement
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: