Thursday 3 December 2009

CRM FetchXMLBuilder ...

While developing applications (Plugins, Workflows, Service Portals) for CRM, it is a quite common requirement to build FetchXML or write search logic using QueryExpressions of CRM SDK API.

I found an excellent tool called Fetch XML Builder that helps you prepare FetchXML by building queries and joins using an intuitive user interface.

Let me tell you that there is a smarter way to extract FetchXML and this is how you can do it:

  1. Open Advanced Find in CRM Build your search criteria in the UI (you can't get a sophisticated UI than this :-))
  2. Save the query
  3. Hit Find




  4. View the source of the results page and search for the hidden field named "fetchXML".




Now, my attempt is not to outsmart the tool - Fetch XML Builder, but let me tell you how you can use this tool for some useful code :)

  1. Launch Fetch XML Builder
  2. Click "Import" -> "User Query" to import the query that we built in CRM




  3. Now, let the tool generate code for you by clicking on "Create Code" -> "QueryExpression"
Let the effort that had gone towards building an intuitive UI for FetchXMLBuilder be appreciated :-)

Windows Service Monitor ...

.NET makes life lot lot easier at times. Recently I came across a requirement where it is required to monitor the installed windows services and send a notification (via Email or an SMS) to designated people letting them know that a windows service of interest got stopped.

I searched for a freeware in Google and found that all the products out there can send an email when a service "fails" not when a service is stopped.

I ended up writing a small windows based application that looks like below:




The program monitors the selected services at regular intervals of time (configurable) and sends an email when a selected service is stopped (one email per service).

The source code for the above program is here.