Sunday, April 23, 2017

Dynamics CRM Parental Relationship behaviour

Recently in one of our projects the client came up and said that something strange is happening with created notes on a particular custom entity. What they said was there were some notes created against a custom entity record and one of the new users logged in and created a new note against that record and when another user logged in to check the record , it showed all the notes were modified by the new user, which the new user hadn’t do.

This was a strange behaviour and the client wanted to know whether we have done any custom plugins or workflows around notes. We didn’t have any and it puzzled us too.

We started trying to replicate this in our development environment to find out the reason why it was happening. We were able to replicate it sometimes and but sometimes it didn’t happen. So we drilled down to see why it was happening like that.

We were able to track it down and confirm that this only happened when we were changing the owner of the particular record. One of my colleague (Shane C) wanted to have a look at in the relationship to find out whether it is happening because of that, and he was dead right about it.

The relationship between the custom entity and the notes was a parental relationship and which meant if the owner was changed then the owner of the notes belonging to that record would be changed as well. How it works is given below.

Custom Record A is having owner AA.
Custom record A is having 5 Notes and the notes are belonging to 3 different users.

User BB comes and changes the owner of Custom record A to User DD.
According to the parental relationship as it has been setup all the Notes associated with Custom record A would be changed to Owner DD now.

Also what will happen is, all the Notes would have User BB as the modified user as well. This is because of the parental relationship changes the Owner of the notes and the user who changed the Owner of custom record would come down as the user who did the Owner change in Notes as well. This is expected behaviourJ.
It took some time to figure this out.


You can change this behaviour by changing the relationship from Parental to Cascade, but it is up to the requirement of the organization. This might not be recommended as well.

No comments:

Post a Comment

Retrieving Calendar of a Bookable Resource in Dynamics

There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...