Friday, November 21, 2008

U2U CAML Query Builder Feature

This feature has been developed to ease the work of a SharePoint 2007 developer. It consists of an application page where you can build a CAML query. The CAML query itself is stored in a list from where you can further work with it. You can download it from here: http://www.u2u.be/res/Tools/SharePointCamlQueryBuilder.aspx


If you want to know more about CAML, please visit the following page: http://msdn.microsoft.com/en-us/library/ms462365.aspx


This tool is one of the several tools developed by U2U to ease the work with CAML Query. I like this tool most because is integrated in SharePoint and if you'd like to create a new CAML query you just have to activate this feature for the site collection you work on an a new link in any of your Action tab of your any list instance will appear: Build a new CAML Query. To build a new query just press this new option and you're ready to start.

A very intuitive page is used for this task - is very similar with the create a new view option for every SharePoint list: you can select the columns you want to have in the query, you can put an order by statement, you can filter the results and you can set some other more specific properties for the CAML query.

The last step to build a query is to Preview the results. Here you'll have options to export the CAML query to C#, VB.NET, CAML and the tool will generate the code for that:

You have even the option to select the returning type of the method it will generate: DataSet or SPListItemCollection and to preview the results as a table.
You just have to copy paste the code this tool will generate into your project and that's it - you have a new CAML query in your SharePoint solution.