Jan
12
2012

Tools for building CAML Queries

Checkout

  • U2U CamlQueryBuilder: http://www.u2u.be/Tools/wincamlquerybuilder/CamlQueryBuilder.aspx
  • Stramit Caml Viewer: http://spcamlviewer.codeplex.com/
Jan
12
2012

Need to write a CAML Query that filters against a Lookup Column?

There are two options to do this -- one is based on the value and the other on the ID.  Unfortunately MSDN doesn't provide any help at all on the 2nd option.

Standard what (based on value):

<Where>
    <Eq>
        <FieldRef Name=”Category” />
        <Value Type=”Lookup”>My category</Value>
    </Eq>
</Where>

And by ID:

<Where>
    <Eq>
        <FieldRef Name=”Category” LookupId=”TRUE” />
        <Value Type=”Lookup”>234</Value>
    </Eq>
</Where>