Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

In SharePoint 2010 client object model (JavaScript), I am using this caml query to download list items.

There is a column called 'Office' and in it, there are several check boxes (i.e. its a multi-select field). I am looking to get the items where the checkbox in the Office field, that has the name 'Toronto' is checked. I don't want to consider the values of the other checkboxes in the Office field. This query below is not working though because I am getting 0 items, when I know I should be getting more.

var camlquerystring = "
<View>
<Query>
<Where>
<Eq>
<FieldRef Name='Office'/>
<Value Type='Boolean'>
Toronto
</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name='Modified' Ascending='FALSE' />
</OrderBy>
</Query>
</View>";   

Does anyone know what is wrong?

Thanks.

share|improve this question

2 Answers 2

Change <Value Type='Boolean'> to <Value Type='Text'> or <Value Type='MultiChoice'>.

Source: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopmentprevious/thread/b20b1945-4b73-4320-8666-957650dc6a20

share|improve this answer

CAML and Querying Boolean Fields By Erkka PeltoniemiFebruary 22 201016 comments Today I had some trouble trying to filter out items by a field of type Boolean. I have a custom content type definition which has a FieldRef to a Field:

  <Field
   Type="Boolean"
   DisplayName="IsHeadlineDisplayName"
   Description="IsHeadlineDescription"
   Required="TRUE"
   Group="SharepointBluesCustomFields"
   ID="{3166A1DF-3EE9-4757-8344-B65BC2482261}"
   SourceID="http://schemas.microsoft.com/sharepoint/3.0"
   StaticName="IsHeadline"
   Name="IsHeadline" />

As my first shot at trying to filter out the records I wrote this CAML query:

<Where>

        <Eq>
          <FieldRef Name='IsHeadline' />
          <Value Type='Boolean'>TRUE</Value>
        </Eq>
      </Where>

As a new comer to the world of Sharepoint development I expected this query to return all of the records which have a IsHeadLine field set to true, yet when I fired the query with SPList.GetItems method the engine would happily return all of the records regardless of their IsHeadline field's value. As Sharepoint doesn't seem to be too consistent on case sensitivity I first thought this was a case sensitivity issue but the query kept returning the same results regardless of how I wrote my parameter.

Turns out you can treat the Sharepoint Boolean fields much the same way as you may have gotten used to doing with T-SQL. With Integer types. 1 representing positive and 0 a negative value.

So I modified my CAML query a bit:

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

This solved my problem and now the engine is finally returning me the proper records.

this was sourced from http://www.sharepointblues.com/2010/02/22/caml-and-querying-boolean-fields/

share|improve this answer
    
But this is when your field has 1 checkbox. But my field called Office has 6 checkboxes, one of them is called Toronto. How can I write the caml query to get the items where the Toronto checkbox in the Office field is checked? –  omega May 29 '13 at 16:10
    
It looks like you would need to return just the Office field itself and then iterate over the values to determine which ones are true or false.. Looks like this is not supported –  Joseph D Surgeon May 29 '13 at 16:17
1  
Queries for multi-value lookup fields and users Because multi-value lookup fields are returned as a string of multiple values, there is no way to query for them (for example, the equivalent of an Includes element or NotIncludes element is not supported). msdn.microsoft.com/en-us/library/fp142385(v=office.15).aspx –  Joseph D Surgeon May 29 '13 at 16:17
    
Yes there is social.msdn.microsoft.com/Forums/en-US/… –  omega May 29 '13 at 17:02
    
Well there you go! –  Joseph D Surgeon May 29 '13 at 17:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.