SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to build a CAML - Query using the IN - Tag. The queried Column is a lookup-field to a Title of another list. When I query using the text-property everything works fine:

   <Where>
      <In>
         <FieldRef Name='page' />
         <Values>
            <Value Type='Lookup'>page1</Value>
            <Value Type='Lookup'>page2</Value>
            <Value Type='Lookup'>page3</Value>
         </Values>
      </In>
   </Where>

This is giving me the wanted result: All rows with Lookups to page1, page2 oder page3 are returned.

When I try to achieve this using the IDs instead I get no results at all:

<Where>
      <In>
         <FieldRef Name='page' LookupId='True' />
         <Values>
            <Value Type='Lookup'>5</Value>
            <Value Type='Lookup'>4</Value>
            <Value Type='Lookup'>3</Value>
         </Values>
      </In>
   </Where>

I rechecked the IDs a dozen times. They are correct. When I change the query to multiple OR-Operations it works fine.

Is this a known limitation of SharePoint 2010 or do I just have to insert a "magic" word somewhere?

share|improve this question
3  
make Type='Integer' instead of Lookup: <Value Type='Integer'>5</Value>, – Arsalan Adam Khatri Oct 30 '12 at 13:28
    
Thanks. Worked. The Caml Builder confused me there :) – Ole Albers Oct 30 '12 at 13:30
up vote 6 down vote accepted

make Type='Integer' instead of Lookup: <Value Type='Integer'>5</Value>

share|improve this answer
    
wow, you're a lifesaver! thanks – MdMazzotti Oct 29 '15 at 16:46

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.