Month: September 2017

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!

Microsoft Dynamics CRM form on load error with or without javascript

Users Sometimes experience an error while opening a contact/any entity. Its an intermittent error and not reproducible all the time and for all users.

Error looks like this in Dynamics CRM UI :

1300.j1.png-600x600

 

When you download the error logs ; below is found:

TypeError: Cannot read property ‘form_onload’ of undefined

    at eval (eval at RunHandlerInternal (http://organization/form/ClientApiWrapper.aspx?ver=2115568044:153:1), <anonymous>:1:42)

    at RunHandlerInternal (http://organization/form/ClientApiWrapper.aspx?ver=2115568044:158:1)

    at RunHandlers (http://organization/form/ClientApiWrapper.aspx?ver=2115568044:117:1)

    at OnScriptTagLoaded (http://organization/form/ClientApiWrapper.aspx?ver=21

 

Resolution:

I created a solution, added the contact entity with forms and exported the solution. Opened the customization XML and found below.

The error has to do with InternalHandlers that is calling a library and a function form_onload  which is somehow attached to this event Hence I had commented out the below InternalHandler property.

 

<event name=”onload” application=”true” active=”true”>

<!–<InternalHandlers>

                    <Handler functionName=”Mscrm.ContactMainSystemLibraryWebResource.form_onload” libraryName=”Contact_main_system_library.js” handlerUniqueId=”4ea24ebd-795d-434e-af94-6812c3867b54″ enabled=”true” />

                  </InternalHandlers> –>

<Handlers>

<Handler functionName=”custom function” libraryName=”contact.js” handlerUniqueId=”{a2a97e43-583d-a4be-3dcb-2369a34a4193}” enabled=”true” parameters=”” passExecutionContext=”false” />

</Handlers>

</event>

 

Saved the customization.xml file and zipped the solution; imported back to CRM.

Hope this helps!

Cheers