|
|
|
|
U2U CAML Query Builder for SharePoint 2003 and SharePoint 2007 (Windows Version)
|
|
|
|
|
Downloads
|
|
|
For SharePoint 2007, download version 3.1.0.0
For SharePoint 2003, download version 2.1.0.0
|
|
|
|
|
Build and test CAML Queries for SharePoint interactively with the U2U CAML Query
Builder.
|
|
|
CAML (Collaborative Application Markup Language) is an XML-based query language
that helps you querying, building and customizing Web sites based on Windows SharePoint
Services. The XML elements define various aspects of a WSS site.
The tool will help you build, test and execute your CAML Queries. Detailed documentation is included
in this document. This version of the tool only let you build CAML queries for execution against lists.
|
|
|
We provide you with 3 things:
- A Windows application you can use to connect to your portal or team site and build
your CAML query string in a WYSIWYG manner. (U2UCamlCreator.exe)
- A small assembly you can reference helping you with the execution of your CAML query
string within your code using the SharePoint object model. (U2U.SharePoint.CAML.Server.dll)
- A small assembly you can reference helping you with the execution of your CAML query
string within your code using the SharePoint web services. (U2U.SharePoint.CAML.Client.dll)
|
|
|
|
|
Content of this User Guide
|
|
|
|
|
|
|
|
What can you expect from this tool?
|
|
|
With this tool you can easily build CAML queries for SPQuery in the SharePoint object model and for
querying and updating lists via the SharePoint web service Lists.asmx. The user interface is very intuitive
and is explained on the next pages.
The tool can run on the server where you can build queries for both the SharePoint object model and the SharePoint web
services. You can also install the tool on a client but in that case you can only build queries for the SharePoint web
services as you won't have access the the SharePoint dlls.
CAML for creating views, list definitions, site definitions are NOT included in this tool.
|
|
|
|
|
A small example
|
|
|
I will illustrate the use of the U2U CAML Query Builder using a small example of an
Employee list that was uploaded using the AdventureWorks MS Access database.
|
|
|
|
|
|
|
|
|
|
Start the Application
|
|
|
Double click the U2UCamlCreator.exe to start the query builder application. You have to fill out the URL
to your SharePoint site. You can set the necessary credentials. Choose the mode you want to work in:
if you run the application an the server where SharePoint is installed you can opt to build the CAML query
with the SharePoint object model. If you have to run the application remotely from another machine or if you want to
build a query that should be passed to a method of a SharePoint web service, you can choose to run against
the SharePoint Web Services.
Click the Connect button to connect to the SharePoint site.
|
|
|
|
|
|
|
|
|
|
Building a simple query
|
|
|
A treeview with the available lists and libraries is displayed at the left side of the application. Select the
list for which you want to execute a query. The query control is loaded: a listbox is populated with the fields
defined on the list.
|
|
|
|
|
|
|
|
|
|
Order By
|
|
|
If you want your list items returned sorted you can define an OrderBy clause. Select a field from the listbox
and check the Order By checkbox. Indicate whether you want to sort in ascending order or in descending order. Take a
look at the CAML query that is displayed in the bottom part of your screen: an OrderBy node is added.
A CAML query can also have a where clause. I refer to following sections on how you can build a where clause.
In the lower panel of the window, you will find the CAML query string written out in full, dynamically changing
as you add or remove fields to the sort order or the criteria. As you notice, it is quite a challenge to construct
this string without the help of the builder.
|
|
|
|
|
Testing your query
|
|
|
The CAML query is displayed in the bottom part of the form. At the right of the query you have a Test button. When
you think your query is ready you can test it out. If you choose to work with the SharePoint object model, the query will be
executed against an SPQuery object. If you choose to work with the SharePoint web services, the query will be
passed to the GetListItems method of the Lists.asmx web service. (You will learn more about this method in
the section "Building a CAML Query for the SharePoint Lists Web Service").
The result is shown in a datagrid in the result tab in the bottom part of the form:
You can change the query by hand in the query editor and click the Test button again. The changed query will be
executed.
Use the Refresh button to rebuild the original query.
You can copy the query string to the clipboard and paste it in your development environment where you need the query.
|
|
|
|
|
Clearing your query
|
|
|
If you messed up your query or you want to try it another way, you can clear your query by
clicking the Clear button in the upper right corner of the form.
|
|
|
|
|
Saving your query
|
|
|
The U2U CAML Query Builder allows you to store the query as a file. Just use the File | Save
File menu item and save it on your file system.
The query is saved in a file with a .caml extension together with necessary information like the
url of the SharePoint site, the list name on which the query was build ad what type of query was build.
|
|
|
|
|
Open your query
|
|
|
When opening the application afterwards, you can load your settings and continue with
your work.
|
|
|
|
|
Continue with Building a CAML Query for the SharePoint Object Model.
|