Hey, I know this is a simple question: How to build a correct CAML Query and test it before put it into the code in case you don’t know deep about CAML?
I have a task list, with default columns and Types are:
And, I also have 2 rows with dummy data like this:
Now, I want to build the CAML Query, which returns the row math with condition: “Due Date” is “November 21” and “% Complete” is “10 %”. How to build the CAML Query and test it in this case ?
Solutions: Modify view and using SharePoint Manager
1. Modify current view by click to “Modify View” at the Ribbon
2. At “Filter” session, simple type what you need here, it should be easy like this:
3. Click “Ok” and yeahhhh, your results will display on current view:
but wait, what I need here is the CAML Query. Where is it ?
And, SharePoint Manager is very powerful tool to help us get the CAML (and many things else). Just open the SharePoint Manager, go to your current view and look at the “Query” at properties tab, copy this, and you will have a correct CAML Query:
<Where><And><And><Eq><FieldRef Name="PercentComplete" /><Value Type="Number">.10</Value></Eq><Geq><FieldRef Name="DueDate" /><Value Type="DateTime">2013-11-21T00:00:00Z</Value></Geq></And><Leq><FieldRef Name="DueDate" /><Value Type="DateTime">2013-11-21T00:00:00Z</Value></Leq></And></Where>