Microsoft Dynamics CRM Duplicate Consolidation Management
December 1, 2009
Posted by on
After receiving a comment on last month’s post I decided to do a follow-up and detail a little further how Microsoft Dynamics CRM manages the merging of duplicate records. For the purposes of this post I’ll stick to using Contacts as the example. However, the same is true for Accounts and many other tables.
For our sample records let’s say we have just two contacts that are duplicates. Contact A has four service calls associated with it. Each of these service calls have relevant data that you want to retain. Contact B has three service calls associated with it and each service call has data that needs to be retained.
Upon merging Contact A with Contact B (so in this case B is the keeper record), there will be seven service calls associated with Contact B. This is accomplished through the use of four data elements in each Contact transaction. These fields are ContactId, MasterId, Merged, and Statecode.
Merged is an indicator field where 1 indicates that the transaction is indeed merged. Statecode is another indicator field indicating active and inactive transactions. In Dynamics a statecode of value of 1 is inactive and 0 is active. Yes, you read that right. Zero is active.
The “magic” of the duplicate consolidation lies in the MasterID field. For consolidated records the MasterID is equal to the unique identifier of the keeper record. So in our example if the unique identifier of Contact B was 1234, the MasterID of Contact A will be 1234. The Merged field would be 1 and Statecode of 1.
In addition to this update, there is another set of updates required in order to “reassociate” each transaction formerly associated with the subordinate record to the new master.
So continuing with our example, the service call entity would need to be updated so that the transactions with the ContactId of the non-master will need to be updated with the master ContactId.
For those transactions which are not merged the MasterID is NULL (no need to store the unique identifier twice).