Table of contents
CAML query builder intro
New modernized CAML query builder gives the great possibility to easily filter SharePoint lists/libraries within a modern interface using extended conditions and options, like row limit, order by, query scope. Also, within CAML query builder you can see the result of your query configuration.
CAML query builder is available in design mode in solution studio for Modern Forms (actions, Lookup/Data lookup and sublist controls configuration), List Actions, Background features (Aggregation, Scheduled Actions, Triggered Actions).
CAML query builder contains three functional tabs: Designer - the main default tab where user can configure the query specifying various conditions:
XML tab will represents configuration of Designer tab in XML format :
and finally you can write your custom query in Custom expression tab.
Note: Custom Expression tab is not available in Aggregation. Also, Designer and XML tabs will be disabled if you use Custom Expression tab to build the query.
Configuration options
To build the CAML query the following conditions can be specified:
Condition | |
View scope |
Specifies the scope for returning list items and folders in a list view. Items/Documents (FilesOnly) – Items scope returns only items under the root in the list/library. Items/Documents and Folders (Default) – returns all items and folders under the root in the list/library Items/Documents recurcive (Recursive) – Items recurcive returns all items in the list/library including items under subfolders . Items/Documents and Folder rescursive (RecursiveAll) – By specifying scope as Items and Folder rescursive, it returns all the items and folders under root with including all items and the folders inside subfolders. |
Order By |
Specifies the sort order of the retrieved items in the list/library (Default, Ascending, Descending) |
Rule/Condition |
Specifies a condition whether to apply the "Where" filter or not. An empty value will skip the condition and apply the filter. In order not to apply filter condition formula should return false or 0. |
Where |
Specifies a query filters: All (all of the conditions are met) and Any (Any of the condition are met). A condition consists of a column operand, a compare operator and either a value or input operand. For value operands the value can be specified by value and also using expression builder (specific per column type). CAML builder allows to add any number of child element to add within 'Any' or 'All' context with further normalizing in the runtime mode. |
View fields |
Specifies the сolumns you want to retrieve by executing the query. View fields is not specified then it will retrieve all the columns of a list. <ViewFields> <FieldRef Name="ID"></FieldRef> <FieldRef Name="Title"></FieldRef> </ViewFields> |
Row limit | Number of Rows to retrieve |
Rule/Condition
Specifies a condition whether to apply the "Where" filter or not. An empty value will skip the condition and apply the filter. In order not to apply filter condition formula should return false or 0.
Note: This option is available only for CAML filter in sublist/sublibrary, Lookup and Data lookup configuration.
Example: you want to configure cascading lookup behaviour for 'Country' and 'Company' columns. When user select the country different companies would be dynamically displaying in the 'Company' dropdown. Additionally it required to display all companies in the dropdown if field 'Country' is not selected.
Such behaviour can be realized by using the Rule: "=[[Country]] != null".
Whole CAML filter in XML format is the following:
<View>
<Query>
<Where Condition="[[=[[Country]] != null]]">
<And>
<Eq>
<FieldRef Name="Country" LookupId="TRUE" />
<Value Type="Counter" ProviderType="LookupId">[[=[[Country.Key]]]]</Value>
</Eq>
</And>
</Where>
</Query>
</View>
Run query
Using 'Run' you can easy see the result of your query configuration:
Note: In a case you use placeholder in query configuration the result of your query depends of the selected item you want to run the query.
Usability features
- Drag & Drop - add and move rows and groups using drag & drop. You can drag and drop one row, as well as a group with multiple rows in it.
- Expand/Collapse - to see more of your query you can expand it
- Info icon - it is available on CAML filters with link to the article for better understanding how to use it