Saturday, 22 June 2013

Introduction to Fetch XML in CRM


What I am about to discuss will probably be very primitive to most CRM developers. In my defense i can only say that the keyword here is “Introduction”. This topic is really going to be for absolute starters from a starter’s point of view.  If time permits I would like this topic to be extended into some parts in where I would like show how to use FetchXml in both server and client end, a glimpse of a code example based on JavaScript which i recently did .Enough said, now let’s start the party,



FetchXml: What, Why and When
FetchXml is an Xml query structure in MSCRM 2011 to retrieve data. Every data request in crm gets converted into one of these query and gets passed to the CRM services. CRM Service (Data / meta data) runs the query to the database and then returns an Xml response to the request. CRM then parses the XML response and puts the information into its place and displays the page. Since most of this process can be done in client end, the whole FetchXml business is visibly fast. It is also the only way to manipulate data for Crm Online solutions.


FetchXml is widely used in creating reports in CRM. You can also use FetchXml, to use in CRM form properties to to access and manage data.




Benefits:
As I have discussed earlier it is the most faster way to access and manipulate data. Through FetchXml, you can do almost all the things you can do in an average workflow.


You can integrate FetchXml with javascript. So it it is very light weight.




Shortcoming
The only improvement factor that i can think of about FetchXml now, is it involves a lot of coding. complicated queries will take even more lines of code which may lead to programmatic mistakes. There are some FetchXml query builder available in the net. Probably the most famous and acclaimed of them is called SwTools available in this web site . Before you dig into it let me remind you that this is a complete third party software so if you use it you pretty much on your own. The software which initially was build CRM 4.0, claims that it works with CRM 2011 as well. I have tried using it and it really works. However it only do retrieve commands (selects). As much as i know it does not do Non Queries. (Did i forget that you can perform Insert/Update/Delete through FetchXml?).

I prefer one that involves a slight more coding but developed by Microsoft. It is called SoapLogger which is available in CRM 2011 sdk. I will discuss about this in future posts.   

No comments: