Filtering SharePoint lists using CAML query

CAML query is supported in BindTuning Web Parts to map data from SharePoint lists. You can create a query to target specific elements in a SharePoint list.

Before we start

If you’re using SharePoint 2013/2016/2019 and Online, you can use a 3rd party free software for creating the query, like U2U Caml Query Builder for SharePoint 2013 (Standalone Edition).

This tool will auto-generate the query, after passing the necessary values.

Use Case

Let's say, for instance, we were wanting to filter our Site Pages document library, so as to retrieve Modern News Posts, while excluding the remaining pages. 

After fine-tuning our source, we need a mechanism to only show News Posts created in the last 90 days

Although it may seem daunting at first, we can utilize U2U's CAML Query Builder, so as to visually create our constraints, as well as leverage the built-in CAML query editor provided by BindTuning's web parts, enforcing those same parameters. 

Creating a Query

To create your own custom CAML Query, follow the steps below: 

  1. The first step will consist in connecting our SharePoint site collection to U2U's interface;
  2. Locate the list and/or document library we want to create filters for;
  3. After successfully accessing our list, we need to create a New Query. This query will accept the underlying columns of the list we are connecting to. 
  4. Utilize the visual interface so as to create your own query.


After successfully creating our custom query, the editor will automatically generate the corresponding structure, as seen below: 

   <And>// have to meet this 2 conditions 
    <Eq> //Equal 
	<FieldRef Name='PromotedState' /> 
     <Value Type='Number'>2</Value> 
    <Leq> //Lower or Equal 
     <FieldRef Name="Created" />
     <Value Type="DateTime" Offset="-90"> // -90 days from today 
   <FieldRef Name='Created' Ascending='False'></FieldRef> // Most Recent to older created element
 <RowLimit>3</RowLimit> // Number of items that you need to show 

Add Query to BindTuning's Web Parts

Most of BindTuning's Web Parts will allow you to add your CAML Query directly, when configuring your source options. 

To add the previously created CAML Query to BindTuning's News Web Part follow the steps below: 

  1. Add a BindTuning News Web Part to the Page and select the option Configure
  2. Under List Settings click on Manage News;
  3. Select Add List and connect to the necessary list or document library (i.e, Site Pages);
  4. Under Filtering Options select CAML Query, and paste the query created above.


Have more questions? Submit a request


BindTuning logo
Copyright Ⓒ 2021 Bind.
All rights reserved.
Privacy Policy
Cookie Policy
              Linkedin BindTuning Twitter BindTuning YouTube BindTuning Instagram BindTuning
Powered by Zendesk