Microsoft Dynamics CRM 2011

Microsoft Dynamics CRM 2011

Wednesday, July 18, 2018

Dynamics CRM Errors when importing unmanaged solution

In this article we see Step by step How to fix Dynamics CRM Errors when importing unmanaged solution , in both CRM 2011 and CRM 2013 .
Several errors can be thrown by Microsoft Dynamics CRM while importing an unmanaged solution from test to production environments, such as "This import has failed because a different entity with the identical name" , or "Field Is Not Unique"...
Usually the causes are differences of schema between fields or entities.

First of all, try to check this 2 things:

1) Schema name and name : have the fields/entities EXACTLY (letter capitalization) the same schema names? (  new_MyField < > new_myfield ) 

2) Schema data types: have the fields/entities EXACTLY the same type? (nvarchar = nvarchar, int = int)

We'll see here in only 10 minutes how to perform a search for the DYNAMICS CRM API web service error codes , such as "0x80044150" or "0x80041a06" , for example :

Errors when importing unmanaged solution
Dynamics CRM Errors importing unmanaged solution


How to fix Dynamics CRM Errors when importing unmanaged solution


Usually, you will get this kind of error while importing a CRM solution:

Dynamics CRM Errors when importing unmanaged solution


The steps are usually as following:
0) open the importing error file and make a search for "0x" to get the error!!!
1) get the hexadecimal error code for the Entity and delete the hexadecimal prefix "0x"
2) search the web for the error without the "0x" prefix
3) re-build any custom Field which has an schema name ("new_myfield") difference
4) re-build any custom Field which has a type difference


1) Step #0: open the log file to find the error :

Dynamics CRM Errors when importing unmanaged solution



2) Step #1: get the hexadecimal Error Code & delete its "0x" prefix :


Dynamics CRM when importing unmanaged solution




3) Step #2: search the Web for the code but without the prefix "0X":


Make a search for "DYNAMICS CRM API web service error codes" , and append the error code:

CRM Errors when importing solution





Dynamics CRM Errors when importing unmanaged

Remember: as long as Microsoft Dynamics CRM uses GUIDs , and they are different between a development environment to a production environment, the only way it has to identify an Entity is its schema name and its type !!!!!!



Happy CRM.....

      by Carmel Schvartzman


כתב: כרמל שוורצמן

Saturday, June 9, 2018

CRM RetrieveMultiple QueryExpression to retrieve the top one last created record

In this article we see Step by step How to write a C# query Microsoft Dynamics CRM QueryExpression  to retrieve the top one last created record/modified record , in both CRM 2011 , CRM 2013 ,CRM 2015 and Microsoft Dynamics 365 .
We'll use the IOrganizationService RetrieveMultiple method with a FilterExpression and a ConditionExpression, to get only one record: the latest one created . We also check an attribute for null values .
Usually this C# code will be run from a Dynamics CRM Plugin.
Download the C# code from the following GitHub repository:


We'll see here in only 10 minutes how to write the CRM query , which will be shown this way , for example :
CRM RetrieveMultiple QueryExpression to retrieve the top one last created record



CRM RetrieveMultiple QueryExpression to retrieve the top one last created record/last modified record


First , you need to set which columns to retrieve. It is strongly recommended that you do not select all columns in an of the Microsoft Dynamics CRM SDK entity :
CRM RetrieveMultiple QueryExpression to retrieve the top one last created record



Next, we create the QueryExpression that will hold the query to be send to the OrganizationService , as follows :
CRM RetrieveMultiple QueryExpression to retrieve the top one last created record


There, we add an OrderExpression to sort the records acording to its "createdon" or "modifiedon" attribute.


Then, we cut the results to just the first result and circumscribe them to the first page:

CRM RetrieveMultiple QueryExpression to retrieve the top one last created record



Then, we can check some determined attribute to contain a value - with the not null ConditionOperator:

CRM RetrieveMultiple QueryExpression to retrieve the top one last created record



And include all conditions in a FilterExpression, into the Criteria:
CRM RetrieveMultiple QueryExpression to retrieve the top one last created record





The complete query will look something like this (this code has been tested , and works very well) :

CRM RetrieveMultiple QueryExpression to retrieve the top one last created record





The steps are as follows:
0) Set which columns to retrieve.
1) Create the QueryExpression
2) Add an OrderExpression
3) Check some determined attribute to contain a value using a ConditionOperator (optional)
4) Include all conditions inside  the Criteria as a FilterExpression
5) Send a RetrieveMultiple with the QueryExpression


Happy CRM.....

      by Carmel Schvartzman


כתב: כרמל שוורצמן