-
<Query>
<OrderBy>
<FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
</OrderBy>
<Where>
<And>
<Neq>
<FieldRef Name="Status"></FieldRef>
<Value Type="Text">Completed</Value>
</Neq>
<IsNull>
<FieldRef Name="Sent"></FieldRef>
</IsNull>
</And>
</Where>
</Query>
- Figure: Example of CAML query
You can see - CAML is essentially the same as SQL WHERE syntax, but wrapped in an XML format.
Problems with CAML:
-
CAML is XML and is case sensitive – including attributes names.
-
<Query>
<Where>
<Or>
<Eq>
<FieldRef name="Status" />
<Value Type="Text">Completed</Value>
</Eq>
<IsNull>
<FieldRef Name="Status" />
</IsNull>
</Or>
</Where>
</Query>
- Figure: Example of CAML query
-
SharePoint is not good at telling you if you made a mistake with your CAML query.
- Figure: Debug error message
-
Hard to debug.
Tips: Use 3rd Party tools - U2U CAML Query Builder
- Figure: U2U CAML Query Builder
Note: U2U CAML Builder is the best tool that we have. There are some occasional UI and interface issues, but for creating CAML and testing it against live SharePoint lists it gets the job done. And it’s FREE!