Hi I have a SharePoint list to be queried for my Desktop App and I want to retrieve only the Active Members but when I queried I got only the users who aren't active. What is wrong with my CAML query?
camlQuery.ViewXml = "<<"View">><Query><Where><Eq><FieldRef Name='Active'/><Value Type='Boolean'> " + true + "</Value></Eq></Where></Query></View>"";
I tried the following as well
camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name='Active'/><Value Type='Boolean'> true</Value></Eq></Where></Query></View>";
and
camlQuery.ViewXml = "<Query><Where><Eq><FieldRef Name='Active'/><Value Type='Boolean'> true</Value></Eq></Where></Query>";
Please help as I'm new to CAML.
What is CAML query in SharePoint? CAML stands for Collaborative Application Markup Language and we use CAML to define queries against SharePoint list data or library data. And then we can use the SharePoint CAML query with CSOM or JavaScript or Server Object model. CAML is an XML-based query language.
Save yourself some grief and use a tool to help build up CAML queries such as U2U's Caml Query Builder.
You need to use 1 and 0 (not true and false) in the query, so
<Query><Where>
<Eq><FieldRef Name="Active" /><Value Type="Boolean">1</Value></Eq>
</Where></Query>
This Works for me
camlQuery.ViewXml = "<View>" + "<Query>" + "<Where>" + "<Eq>" +
"<FieldRef Name='Active'/>" + " <Value Type='Boolean'>" + "1" + "</Value>" +
"</Eq>" + "</Where>" + "</Query>" + "</View>";
Use the value type Bool
and it works with "true", "True" or "TRUE"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With