web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Passion Dynamics / Microsoft Dynamics CRM Impo...

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

Rawish Kumar Profile Picture Rawish Kumar 13,758

Few days back I started getting this strange issue with managed solution import in dynamics crm 2016, after doing some search I found the below solution that i am going to share with you.

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!

Comments

*This post is locked for comments

  • Rawish Kumar Profile Picture Rawish Kumar 13,758
    Posted at

    I/microsoft dont recommend doing any CRUD operation in dynamics crm on SQL directly.

  • yleclerc Profile Picture yleclerc 1,549
    Posted at

    Step 3: Instead of using the API, could this be done using SQL Management Server Studio?