Tag: 0x80040237

Microsoft Dynamics CRM Import Error 0x80040237: Cannot insert duplicate key

When looking at the import log, check whether the error occurred below the “Entity Ribbon” Item Type:

error import

If this is the case, the most likely cause is duplicate or corrupt CustomControlDefaultConfigs. These are the control configurations that you can add as part of the CRM 2016 new features.  Some forums indicate that there are bugs in CRM for transporting these records which were fixed in SP1, Service Update 5. In the meanwhile the easiest workaround identified so far is to delete from source environment the CustomControlDefaultConfigs following these steps:

  1. Identify which entity caused the failure. For example, from the screenshot above we can see the failure comes from the particular entity.
  2. Open the solution customizations.xml file and find the problematic entity. Under that entity find the CustomControlDefaultConfigs node and extract the Guid(s) of the default CustomControlDefaultConfigId:xmlnew
  3. Now delete from the source environment this record. This cannot be done via UI unfortunately so it must be done using the API. Below is an example line of code on how to achieve this:

service.Delete(CustomControlDefaultConfig.EntityLogicalName, new Guid(“404c2f18-9142-e611-80df-000d3ab010db”));

  1. Publish all customizations in source environment
  2. Verify in database of source environment that the record is deleted. This line should return no values (replace with the appropriate GUID):

select * from CustomControlDefaultConfig where CustomControlDefaultConfigId = ‘404c2f18-9142-e611-80df-000d3ab010db’

 

  1. Re-export the solution and import again.

 

Hope this helps!

Cheers!