SharePoint CAML Query Helper for SharePoint 2013 On premise Online SharePoint 2010 and 2007

SharePoint CAML Query Helper for SharePoint 2013

Here we will discuss how we can use SharePoint CAML Query Helper in SharePoint 2013 Online. SharePoint CAML helper tool will help build and test SharePoint CAML queries in SharePoint 2013 On-premise as well as SharePoint 2013 Online Office 365 environment. This tool is very much compatible with SharePoint 2010 and MOSS 2007.

In my previous article, we have discussed CAML Query Builder in SharePoint 2013 Online.

Another feature of this tool is you can export fields details and query results in CSV.

Steps to use CAML query helper:

First of all download the tool from this GitHub.

Once your download and unzip you will see two folders. In one folder as the name suggest a setup for MOSS 2007 and SP2010. And another folder contains the ext for SP2013. Open SP2013 folder and double click on SPCAMLQueryHelper2013.exe.

This will open the dialog box and ask you how to connect to the SharePoint site. You can connect by using SharePoint object model (in this case tool needs to be installed in the server where SharePoint has been installed). Also, you can connect by using a web service. And also you can connect to your Office 365 SharePoint online site by using web services. First, we will see how we can connect to an on-premise site.

Select Use SharePoint Object Model and click on SUBMIT.

SharePoint CAML Query Helper for SharePoint 2013
SharePoint CAML Query Helper for SharePoint 2013

Then it will ask you to give the Site URL, enter the URL and click on Load. This will load all your List and Document libraries. Then you can double-click on a particular list and it will load the columns details in the List Info tab, you can also get more details about the list using the MORE LIST DETAIL button as shown in the fig below:

SharePoint CAML Query Helper for SharePoint 2013 On premise Online SharePoint 2010 and 2007
SharePoint CAML Query Helper for SharePoint 2013 On-premise Online SharePoint 2010 and 2007

Also read: Create Visual WebPart using Visual Studio 2013 in SharePoint 2013

Connect to SharePoint Online Site:

Reload the tool again, And this time Choose option “Use Web Services (Office 365)” and then enter the Username and Password like below:

SharePoint CAML Query Helper for SharePoint 2013 On premise Online SharePoint 2010 and 2007
SharePoint CAML Query Helper for SharePoint 2013 On premise Online SharePoint 2010 and 2007

Then in the Next screen give the Site URL and click on LOAD. It will Load all the lists and Libraries from the SharePoint Online site.

SharePoint CAML Query Helper for SharePoint 2013 On premise Online SharePoint 2010 and 2007
SharePoint CAML Query Helper for SharePoint 2013 On premise Online SharePoint 2010 and 2007

Now double click on the particular list for which you want to write the query. This will load the list information in the List Info tab. You can able to see more details about the list by clicking on the “MORE LIST DETAIL” button. Apart from this, you can also export all the List Information by clicking on the EXPORT button.

SharePoint CAML Query Helper for SharePoint 2013 On premise Online SharePoint 2010 and 2007
SharePoint CAML Query Helper for SharePoint 2013 On-premise Online SharePoint 2010 and 2007

Read: Export SharePoint 2013 List Items to Word Document using SharePoint Server Side Object Model

Build CAML Query:

To write the query, click on the Query Helper tool. This provides three tabs Query, View Fields and View Attributes.

From the Fields box, you can drag and drop to the Query text box. In the Row Limit box, enter the value (Row limit). Click on the Search button to search the query.

SharePoint CAML Query Helper for SharePoint 2013 On premise Online SharePoint 2010 and 2007
SharePoint CAML Query Helper for SharePoint 2013 On premise Online SharePoint 2010 and 2007

Then copy the code by clicking on the Copy Code button which will generate the CSOM code which will be look like below:

string sQuery = @”<Query><OrderBy><FieldRef Name=””Modified”” Ascending=””FALSE””></FieldRef></OrderBy><Where> <BeginsWith><FieldRef Name=””Title””></FieldRef><Value Type=””Text””>item</Value></BeginsWith></Where></Query>”;
string sViewFields = @”<FieldRef Name=””Title”” /><FieldRef Name=””First_x0020_Name”” />”;
string sViewAttrs = @”Scope=””Recursive”””;
uint iRowLimit = 100;

var oQuery = new SPQuery();
oQuery.Query = sQuery;
oQuery.ViewFields = sViewFields;
oQuery.ViewAttributes = sViewAttrs;
oQuery.RowLimit = iRowLimit;

SPListItemCollection collListItems = oList.GetItems(oQuery);


foreach (SPListItem oListItem in collListItems)
{
}

Hope this will helpful.


You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →