Monday, July 19, 2010

Build CAML Query using Boolean Field

If the field is of type "Yes/No", you may query it with a 1/0 value instead of boolean, for example:

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

or

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

Additional note:
When adding a new Yes/No field to a existing list, we have three values in the list:

True,
False
Null

So we need to use the <IsNull> or <IsNotNull> element in the query, for
example:

<IsNull>
<FieldRef Name="Headline"></FieldRef>
</IsNull
>

No comments:

Post a Comment