Use this program to help build and test SharePoint CAML Queries (Collaborative Application Markup Language). Compatible with WSS 3.0, MOSS 2007, Foundation 2010, and SharePoint 2010. 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, viewfields, 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. Newtonsoft JSON.NET API is used to dump the content of listitems. App.config file can used to specify default Site URL to connect when opening file, also can save credentials to use when connecting to SharePoint using Web Services.Latest News: Connect to SharePoint using Object Model or Web Services. Can run program from computer without SharePoint installed.
- Uses SharePoint Object Model and SharePoint Web Services.
- Compatible with SharePoint 2007 and 2010.
- 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
- 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, www.bandrsolutions.com.