Use this program to help build and test SharePoint CAML Queries (Collaborative Application Markup Language). Compatible with SharePoint 2007, SharePoint 2010,
SharePoint 2013 and Office365
, in one single convenient download containing two EXE files. Very similar to U2U CAML Query Builder for SharePoint 2003 and SharePoint 2007. This app uses the SharePoint Object Model and Web Services to connect to a site
using a URL. Gets all webs in a site, all lists in a web, and all fields/columns in a list. Can export field information to CSV. Also provides interface for building XML CAML Queries, with tools to make it easier managing field names (using drag-drop and copy-to-clipboard
commands). Specify a query, view fields, view attributes, and a row limit (0 to ignore) and run your query. Results are output to a sortable grid and the data can be exported to CSV. The grid shows the fields that are selected in the viewfields.
Source code moved to Github:
Like this tool? Go see my other tools:
11/29/2015 - Latest version SPCAMLQueryHelperOnline available, compatible with SharePoint 2010, SharePoint 2013, SharePoint Online and Office 365. No more SharePoint Object Model, can run from any computer with internet connection to SharePoint. Requires
Latest Changes (as of 5/28/2013):
- Session information is saved and loaded each time program is opened and closed. So the previously entered URL, query, credentials, etc. will be remembered.
- More query sample templates are loaded to help build CAML Queries.
- Netwonsoft API dependency removed, which occasionally caused query errors.
- Exporting grids now uses a proper save file dialog instead of dumping to executable directory.
- Does not load all sites within the currently loaded site anymore. When loading a site collection with hundreds or thousands of sites, this feature would crash the program. The program will now only load the current site entered and display all the lists
in that site.
- More list reflection, added a new button that will load List Details. Opens a new window showing list properties.
- More field reflection, double click a field in the grid and a new window appears showing field properties.
- Uses SharePoint Object Model and SharePoint Web Services.
- Compatible with all modern SharePoint versions: 2007, 2010, 2013, Office365.
- Supports export to CSV for Field info and Query results.
- Copy-to-clipboard and drag-drop columns to Query and ViewFields textboxes (for easier query building).
- Zero-configuration, just click and run (providing a Site Url is only config variable, so maybe 0.1 configuration).
- About/Help window has cheat-sheet for CAML query syntax with examples.
- Open the Views for a List and examine the View Schema CAML (in a dialog window).
- Export Query and View Fields as C# code (ready for pasting into your application to use).
- Choose existing List Views to base a SPQuery.
- Enter View Atributes for a query, like performing a recursive search through folders in a document library (Scope=”Recursive”).
- .NET Framework 3.5, SharePoint 2013 program version uses 4.5
- Run on server with SOM installed
- Or, run on computer that can connect to SharePoint using Web Services
: Choose how you want to connect to SharePoint. You can choose to connect using SharePoint Object Model, which requires this program to be run on a SharePoint server and the current logged in Windows User to have permissions to run SOM
code. Or, you can connect using SharePoint Web Services (asmx SOAP services). Either use the current user's permissions, or enter a username, password, and domain to connect to SharePoint. Once the program is running, you can always change the connection
settings by using the File menu.
Main Program Window
Main program window, enter site-url, click "LOAD", fills list of Sites in Site Collection, and list of Lists in each Site. Double-click a List in the tree to load the List. View operation status messages at bottom of window.
Loading a List
List loaded, first tab shows List Name and GUID, and all SPFields in SPList with common field information displayed. Export the grid to CSV with a single button click. File is dynamically named and added to current execution directory (of EXE file). Also, click
on the "Open List Views" link to open a new dialog window that shows all Views belonging to list, and to examine existing SPView CAML.
Loading a list also fills the Query Helper Fields tree. Can be resorted by Title or InternalName of SPField. Node value is always InternalName since that is what is used by SharePoint for CAML Queries. Double-click a field in the tree to copy the InternalName
to the clipboard. Or, drag the selected field to either the Query or View Fields textboxes. The InternalName will be placed at the end of the textbox wrapped in a CAML FieldRef tag. Also enter View Attributes, like Scope=”Recursive” for folder searching in
Document Libraries. Enter a Row Limit to limit the number of rows returned, or 0 to ignore. Click "SEARCH" to execute SPQuery. If results were found, then the Results tab is automatically focused showing the returned results. If zero results were
found, then the status window will show a message indicating 0 records were found. Click "COPY CODE" to copy the Query and View Fields as C# string code to clipboard, ready to paste into your application. Also, you can now choose a View (that belongs
to the loaded List), to base the SPQuery. This will use the view's query and row limit values (see msdn for more information on the SPQuery(SPView) constructor).
Query results are shown in a grid, that is sortable. The fields returned match the View Fields specified previously. Click "EXPORT" to export the results to CSV in the current execution path.
Opening List Views
Clicking "Open List Views" in main program window opens this dialog window. Double-click a List View name to load the SchemaXML. Use this to analyze existing List Views.
About Window and Cheat-sheet
Click Help->About to load the About dialog window. Here you can find additional information about SPQuery CAML syntax, like a cheat-sheet.
Results to CSV
Example of exporting returned results to CSV.
Data exported in CSV format.
Exporting Field Info to CSV
Example of exporting SPField info to CSV.
Generating C# Code for SPQuery
Example of copying generated C# code to clipboard to paste into application.
Example of the generaetd C# code.
Built in Visual Studio 2008 in a MOSS 2007 environment to ensure backward compatibility with MOSS and WSS 3.0. Tested in Windows Server 2003 32 bit, Windows Server 2008 64 bit, WSS 3.0, MOSS 2007, Foundation 2010, and SharePoint 2010.
Inspired by U2U CAML Query Builder and Stramit SharePoint 2007 Caml Viewer. Thanks!
A product by Ben Steinhauser, brought to you by B&R Business Solutions,