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 compatable with SharePoint 2010 and MOSS 2007.
In my previous article we have discussed about 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 codeplex URL.
Once your download and unzip you will see two folder. In one folder as the name suggest 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 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 on-premise site.
Select Use SharePoint Object Model and click on SUBMIT.
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 b using the MORE LIST DETAIL button as shown in the fig below:
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:
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.
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.
Read: Export SharePoint 2013 List Items to Word Document using SharePoint Server Side Object Model
Build the 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 textbox. In the Row Limit box, enter the value (Row limit). Click on the Search button to search the query.
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.
Download FREE SharePoint 2019 Installation PDF Guide
This FREE PDF contains, Steps by step guide to install SharePoint 2019 Preview, prerequisites, hardware and software new features. First impression to SharePoint Server 2019 new modern site, modern lists and modern document libraries.