3

I am using below CAML query but when I run,it returns all data from document library instead of only corresponding to the < Values> specified in the query

<Query>
<Where>
<In>
 <FieldRef Name='Entity_x0020_Served' />
<Values>
 <Value Type='Text'>Payment Solutions</Value>
 <Value Type='Text'>Third Party Processor</Value>
</Values>
</In>
</Where>
</Query>

Am I missing anything in this? Thanks, Rushikesh

Rushikesh
  • 529
  • 4
  • 18
  • 43

1 Answers1

3

strong textSuch syntax would not work in SharePoint 2007, you would have to make it or(equals "Payment Solutions", equals "Third Party Processor"). Maybe something has changed in SPS2010, but I'd rather suggest you rewrite it in this form.

AND you don't add the Query element to your queries!

<Where> 
 <Or> 
  <Eq>
     <FieldRef Name='Entity_x0020_Served' /> 
     <Value Type='Text'>Payment Solutions</Value> 
  </Eq>
  <Eq>
     <FieldRef Name='Entity_x0020_Served' /> 
     <Value Type='Text'>Third Party Processor</Value> 
  </Eq>
</Or> 
</Where> 

Update Found out this is valid syntax in SPS2010 (http://msdn.microsoft.com/en-us/library/ie/ff625761.aspx). Anyway, you should strip out the Query element.

theChrisKent
  • 15,029
  • 3
  • 61
  • 62
naivists
  • 32,681
  • 5
  • 61
  • 85
  • Thanks for your reply..I will check..I have refered the below link for element [MSDN](http://msdn.microsoft.com/en-us/library/ie/ff625761.aspx) – Rushikesh Jan 24 '12 at 12:24
  • I checked the query which you have suggested to me It works fine :) but how can we use the tag ?? Thanks a lot – Rushikesh Jan 24 '12 at 12:35
  • 1
    Just use the query you started with, but remove the `` and `` fragments. – naivists Jan 24 '12 at 15:21
  • When I use the query by removing and getting following exception... System.ArgumentException: Value does not fall within the expected range. at Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemData WithCallback – Rushikesh Jan 25 '12 at 07:04
  • If this is the Client Object Model you need to keep the `` tags but also add `` and `` around the query. Just for completeness in case some one stumbles across this while searching the Internet. – Robert Kaucher Nov 15 '12 at 16:57
  • Good point, Robert! The same is true, if this query is used via lists.asmx web service! – naivists Nov 16 '12 at 05:20