Yes / No field issue
Hi All,

I am facing an issue with "Yes / No Checkbox" field while fetching results from CAML Query.

I have created one sitecolumn with "Yes / No" checkbox type & added the same to a list, now I am using the below code in CAML Designer to fetch the selected checkbox items.

 <Where>
      <Eq>
         <FieldRef Name='Selected' />
         <Value Type='Integer'>1</Value>
      </Eq>
   </Where>

(OR)

   <Where>
      <Eq>
         <FieldRef Name='Selected' />
         <Value Type='Boolean'>True</Value>
      </Eq>
   </Where>

In the both cases I am failing to fetch the selected items.

Can any one of you help me on this issue?

Let me know if you have any queries.

Regards,
SPUser.
September 26th, 2013 9:18am

use bellow code:
<Where>
      <Eq>
         <FieldRef Name='Selected' />
         <Value Type='Boolean'>1</Value>
      </Eq>
   </Where>

Free Windows Admin Tool Kit Click here and download it now
September 26th, 2013 9:40am

Hi,

Thanks a lot for your response. I have tried this option also, but no luck...:(

Please suggest.

Regards,

SPuser.

September 26th, 2013 9:52am

Ohh....I am wrong, the code was working fine(Posted by me & You), Only mistake was that clicking on "Test" button instead of clicking on "Execute" button.

Thanks,

SPUser.

Free Windows Admin Tool Kit Click here and download it now
September 26th, 2013 10:03am

Hi

   Can you try the below code

          
<Where>
      <Eq>
         <FieldRef Name='Selected' />
         <Value Type='Text'>Yes</Value>
      </Eq>
</Where>
(or)

<Where>
      <Eq>
         <FieldRef Name='Selected' />
         <Value Type='MultiChoice'>Yes</Value>
      </Eq>
</Where>

Thanks

Sowmiya

September 26th, 2013 10:05am

Hi,

I'm guessing you're having an issue not with the query itself. When you don't know how your query should look like you can always create one via UI by modifying view filter. Least for me it shows this and it works just fine:

<Where>
        <Eq>
          <FieldRef Name="RequiresReply" />
          <Value Type="Boolean">1</Value>
        </Eq>
      </Where>

Free Windows Admin Tool Kit Click here and download it now
September 26th, 2013 10:14am

Boolean or Integer both work here in SP 2010 for yes/no box.
October 8th, 2014 10:49pm

FYI.  In SP2013 (15.0.4675.1000), only this worked for me:

<Eq><FieldRef Name='IsIndexed'/><Value Type='Bool'>0</Value></Eq>

When CAML querying in PowerShell for "No" in my Yes/No field "IsIndexed".

Neither of these worked:

<Eq><FieldRef Name='IsIndexed'/><Value Type='Boolean'>0</Value></Eq>

<Eq><FieldRef Name='IsIndexed'/><Value Type='Integer'>0</Value></Eq>

Free Windows Admin Tool Kit Click here and download it now
April 2nd, 2015 7:37pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics