U2U CAML Query Builder revisited

I'm proud to announce the release of my new CAML baby. It is not a Windows application anymore but a real SharePoint 2007 Feature! You can use it from any list or document library in your SharePoint site. You can download the U2UDevFeaturesPackage.wsp package from http://www.u2u.info/SharePoint/U2U%20Community%20Tools/U2UDevFeaturesPackage.wsp.

When you deploy the package, you can activate the Feature in the Site Collection Features gallery.

U2U SharePoint 2007 Additions 

Let me take you for a tour around this exciting new Feature! Open your Internet Explorer (or Firefox if you prefer) and navigate to a list or document library for which you want to build a CAML query. Click on the Actions button and there you see a new feature: Build a CAML Query.

CAML Query Builder

This brings you to a page where in the future you will be able to choose between different developer features but at the moment you can only choose to build a basic CAML query. Click this hyperlink to open the basic CAML Query builder page. Select the fields you want to show…

View Fields

Define a sort order….

Order By

And set some conditions….

Filter On

I don’t think this user interface needs more explanation because it is so easy to use and follows the user experience of the standard SharePoint pages.

You can preview the result of your query before saving it. Clicking the Preview button will open a new page with a result grid.

If your query is ok, you can save it by clicking the OK button. The CAML Query Builder stores your query to a special document library Caml Queries from where you can copy/paste the CAML query into your code, web part or view. Also from here you can preview the result from each query:

Preview results CAML query

For those who are interested in the technical part of it, this Feature consists of a document library definition, two aspx pages and a bunch of user controls. The U2U Developers pages follow the theme of your site and inherit from the SharePoint LayoutPageBase page. An assembly that performs the tasks for building up the CAML query is installed in the Global Assembly Cache. It has all been packaged in a SharePoint solution by using a DDF file and the makecab utility.

I know this is a basic CAML Query Builder that has not yet the possibilities of the previous Windows version but it will soon be extended with DateTime functionality and dropdowns for lookup fields and choice fields.

Installation Steps

This Feature has been packaged as a SharePoint solution package (.wsp). Before you can activate features in a sollution package, you must add the solution to the Solution Store of the SharePoint Central Administration. You can do that by using the command utility stsadm

Perform the following steps to get this Feature up and running:

-    download the package at  http://www.u2u.info/SharePoint/U2U%20Community%20Tools/U2UDevFeaturesPackage.wsp

-          stsadm -o addsolution -filename [Path]\U2UDevFeaturesPackage.wsp to add the solution to the SharePoint solution store.

-          stsadm -o deploysolution -immediate -allowgacdeployment -name U2UDevFeaturesPackage.wsp to deploy the solution to each content url. The attribute allowgacdeployment is necessary because the Feature uses a signed U2U.SharePoint.Caml.dll to build the CAML query behind the scenes.

-          Activate the Featue at site collection level. Navigate to the Site Settings of your site and click on the hyperlink "Go to top level site settings". In the section "Site Collection Administration" click on the "Site Collection Features" hyperlink. Here you can activate the Feature. 

Try it out and let me know what you think about it. If you have questions or suggestions about this Feature or if you want to know more about the technical details, please don’t hesitate to post a comment. 

I hope you will enjoy this feature and this blog!