Caml query builder SharePoint 2013 Online

caml query builder online

CAML know as Collaborative Markup Language is an XML based language for querying and updating SharePoint objects like List and Libraries. CAML helps us retrieving items from a SharePoint list based on various conditions, we can also put order by, can also limits items returns from the query etc. We can use Caml query builder SharePoint 2013 Online to write caml query.


Here we will discuss how we can use CAML Query designer tool to generate CAML queries in SharePoint 2013.

CAML Query Designer is a very user-friendly tool and easy way to generate CAML queries from SharePoint 2013 list. Through this tool, you can also be able to generate code snippets for CAML, SharePoint server object model, client object model code, JavaScript client object model code, Rest API, Web services and PowerShell.

Download Install and Use SharePoint CAML Query Designer

First download CAML designer from this URL.

To start connecting to a site click on CONNECTION, then click on the particular button on which environment, Here I clicked on Office 365 button to connect to the Office 365 SharePoint Online site. Then it will ask you to enter the Username and Password and then click on Connect as shown in the fig below:

caml query builder online
caml query builder online

Once the site loaded, all the SharePoint object will be loaded. Click on the particular list for which you want to generate the CAML query. Then click on the ViewFields and drag and drop the fields you want to query.

Then click on the Where to generate the conditions. Here I am trying to filter based on the First Name column. So I drag and drop the First Name column. Writer click on the circle to see the operators like below:


Caml query builder SharePoint 2013 Online
Caml query builder SharePoint 2013 Online

Now Here I gave the condition as First Name contain “Item”. Then the query will be modified and displayed like below:

caml query builder sharepoint online
caml query builder sharepoint online

You can go to the Query Options tab and change various options. I have changed here the Row limit. And it will show the query like below:

caml query in sharepoint 2013 examples
caml query in sharepoint 2013 examples

You can see the test results in the Test tab like below:

u2u caml query builder for sharepoint 2013 online
u2u caml query builder for sharepoint 2013 online

You can copy the code generated by Server OM code, CSOM.NET code. CSOM Rest API code, Web Services code & PowerShell code. You can take the code from various tabs.

caml query sharepoint 2013
caml query sharepoint 2013

SPList spList = spWeb.Lists.TryGetList(“TestList”);
if (spList != null)
{
SPQuery qry = new SPQuery();
qry.Query =
@” <Where>
<Contains>
<FieldRef Name=’First_x0020_Name’ />
<Value Type=’Text’>Bk</Value>
</Contains>
</Where>”;
qry.ViewFields = @”<FieldRef Name=’First_x0020_Name’ /><FieldRef Name=’Title’ /><FieldRef Name=’ID’ />”;
qry.RowLimit = 100;
SPListItemCollection listItems = spList.GetItems(qry);
}

Generate Site Data Query using CAML Designer 2013:

We can also generate Site Data Query by using the CAML Designer. Choose Site Data Query option from the top and then you can see see the query like below:

SharePoint CAML Query tutorial
SharePoint CAML Query tutorial

SPSiteDataQuery qry = new SPSiteDataQuery();
qry.Query =
@” <Where>
<Contains>
<FieldRef Name=’First_x0020_Name’ />
<Value Type=’Text’>Bk</Value>
</Contains>
</Where>”;
qry.ViewFields = “<FieldRef Name=’First_x0020_Name’ /><FieldRef Name=’Title’ /><FieldRef Name=’ID’ />”;
qry.Lists = “<Lists ServerTemplate=’100’/>”;
DataTable resultTable = spWeb.GetSiteData(qry);

You may like following SharePoint CAML Query examples:



Hope this will be helpful for you to understand CAML query builder for SharePoint 2013 Online.

Check out Best Alternative to InfoPath -> Try Now

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 →