Things to be considered while using duplicate detection feature in CRM 2011
In CRM you can create “Duplicate detection rules” to avoid duplicate records in to the system.
Below are the scenarios I observed with duplicate detection in CRM 2011
Enabling duplicate rule while creating/Updating records using CRM service
- By default, when you execute a Create or Update request using the CRM Service, the record will be created/updated without checking for duplicates
- We can force the platform to check for duplicates by setting the “SuppressDuplicateDetection” optional parameter to “false”
- You get “A record was not created or updated because a duplicate of the current record already exists.” exception it matching record already exists
CreateRequest req = new CreateRequest();
Account myAcc = new Account(){
Name = “Rajeev”,
};
req.Target = myAcc;
req.Parameters[“SuppressDuplicateDetection“] = false;
try{
service.Execute(req);
}
catch (FaultException<OrganizationServiceFault> ex){
if (ex.Detail.ErrorCode == -2147220685){
// duplicate detected: Handle it here
}
else{
throw;
}
}
Enable/Disable duplicate detection rules while data import
Using “Duplicate Detection Settings” we can turn the duplicate detection rules on/off while data import. It’s a system level setting applicable to all imports
You can also use the “Allow Duplicates” option, right at the time of Import to turn off the duplicate detection rules
The “Allow Duplicates” option works based on the duplicate detection settings and duplicate detection rules defined.
If you choose
- Yes
- It wont fire the duplicate detection rules
- No
- It will fire the duplicate detection rules
Duplicate Detection Rules Automatically get Unpublished
- By design, whenever any entity metadata is changed all duplicate rules associated with that entity are unpublished
- Whenever you import a solution you release, if the solution has customization change for an entity, say for ‘Account’ entity then the duplicate detection rule for ‘Account’ would turn into unpublished state.
- So whenever you imported a solution make sure your duplicate detection rules are in published state
🙂