Showing posts from July, 2014

Different Behaviours of IOrganizationService.Create Method Triggered Synchronously and Asynchronously

When I have to create a duplicate records with common attribute values, I usually just write a Create line of code in the loop without re-initialising the object.

Entity testRecord = new Entity("new_testentity"); testRecord["new_parentrecordid"] = new EntityReference("new_testparententity", parentEntityId); for (int i = 0; i < itemCount; i++) { testRecord["new_serialno"] = i + 1; service.Create(testRecord); }
Above set of code always work in console or web application that connects to CRM web service or in synchronous plug-in.
But recently, I had to change one of my plug-ins from synchronous execution mode to asynchronous resulting in the plugin failed with error message below. It occurs same if I trigger the same code as custom workflow activity.

A record with these values already exists. A duplicate record cannot be created. Select one or more unique values and try again
Exception: System.ServiceModel.FaultException`1…

Scheduling Recurring Dynamics CRM 2011/2013 workflows with FetchXML for more than 5000 records

For most of the CRM implementations, running batch job (to update status, trigger notification, etc.) is unavoidable. But when it comes to deploying those batch jobs console applications on the server, it is kind of a hassle to go to the server and replace the .exe of update the app.config file.

If you can replace those scheduler applications with custom workflow and trigger by timeout recursively, configuration and deployment of the logic is more seamless since everything can be packed up together in a single solution and deployed  remotely via CRM Solution Import. (By the way, here are some excellent tips from Dynamics CRM Tip of the Day about wait and timeout workflows)
Tip #121: Don’t use wait conditions
Tip #122: If you must use waiting workflows
Tip #123: Waiting for Godo in CRM workflows
Tip #124: But wait, there is more
Tip #125: The wait is over

But even with those recursive timeout workflows, there are some disadvantages. The waiting ones are still hogging some of the resource wh…

Difference between QueryByAttribute vs QueryExpression vs FetchExpression

In this post, I am going to explain the difference between QueryByAttribute vs QueryExpression vs FetchExpression and the suggestion of when to use which one.

I just added QueryByAttribute in this post just because it is one of the class which inherits from QueryBase but obviously, it is used for simple one entity query with one or more equal conditions which are combined using "AND". So, if your query is very simple enough with such limitation, you may use it instead of QueryExpression to save entering ConditionExpression, ConditionOperator.Equal and stuffs. But there is one more limitation that there must be at least one attribute condition to use QueryByAttribute. So, you cannot use it to count all records of a particular entity either. Other than that, there is nothing else to mention about QueryByAttribute since I will be more emphasising about the difference between QueryExpression and FetchExpression.

Starting from CRM 2011 SDK, we are able to use FetchExpression whic…