Friday, October 19, 2007

building fast and efficient crm 3.0 queries server side

CRM 3.0 comes with built-in support for building custom queries to access data with the power and flexibility of SQL.

In CRM this is done using a Fetch xml statement.

While looking around the net for any half decent tutorial i found this piece of very well written software, i know find it indispensable, FetchXML Builder.
I won't explain how to use the software given that there already is some documentation on the site and it is pretty self explanatory.

Once you have created your query, use the following code to "fetch" the result:

string resultsSet = service.Fetch(fetch);

it will return among other things a "result" element within the main "resultset" element.

To iterate throguh the result use this code:

XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(ResultsSet);

foreach(System.Xml.XmlNode node in xdoc.SelectNodes("resultset/result"))
{

}

Oshri Cohen

Labels: , ,

Links to this post:

Create a Link

<< Home