Question

i am a beginner in sharepoint using CAML query to get a list of user items from share point list.

the data i have is userid list like below:- 1 2 3 4 5

now I want to write CAML query to retrieve the user items from share point list where the userid in (1,2,3,4,5)

Was it helpful?

Solution

If you want to filter data by user ID you need to set LookupId="TRUE" for Author field:

<Eq>
  <FieldRef Name="Author" LookupId="TRUE" />
  <Value Type="Integer">1</Value>
</Eq>

If you want to use multiple values for this field you should check IN Element. So your CAML should look like this:

 <In>
  <FieldRef Name="Author" LookupId="True" />
  <Values>
    <Value Type="Integer">1</Value>
    <Value Type="Integer">2</Value>
    <Value Type="Integer">3</Value>
  </Values>
</In>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top