5

When I run the following query I get an error:

<Where>
   <And>
      <Eq>
         <FieldRef Name="IssueLOB" LookupId="TRUE" />
         <Value Type="Lookup">1</Value>
      </Eq>
      <Eq>
         <FieldRef Name="IssueBucket" LookupId="TRUE" />
         <Value Type="Lookup">1</Value>
      </Eq>
      <Eq>
         <FieldRef Name="IssueStatus" LookupId="TRUE" />
         <Value Type="Lookup">1</Value>
      </Eq>
  </And>
</Where>

However, when I run the following query(minus one of the Eq statements) everything works fine:

<Where>
   <And>
      <Eq>
         <FieldRef Name="IssueLOB" LookupId="TRUE" />
         <Value Type="Lookup">1</Value>
      </Eq>
      <Eq>
         <FieldRef Name="IssueBucket" LookupId="TRUE" />
         <Value Type="Lookup">1</Value>
      </Eq>
   </And>
</Where>

Can anyone point me in the right direction? Thanks very much in advance.

2 Answers 2

9
<Where>
<And>
<Eq><FieldRef Name="IssueLOB" LookupId="TRUE" /><Value Type="Lookup">1</Value></Eq>
<And>
<Eq><FieldRef Name="IssueBucket" LookupId="TRUE" /><Value Type="Lookup">1</Value></Eq>
<Eq><FieldRef Name="IssueStatus" LookupId="TRUE" /><Value Type="Lookup">1</Value></Eq>
</And>
</And>
</Where>

This should work!

You should use some CAML Query Builder like U2U Caml Query Builder, there are many other available!

4
  • Thanks for this Arsalan. I actually came to the same conclusion minutes after I posted this query. Thanks very much.
    – E7AD
    Commented Nov 22, 2012 at 22:53
  • No problem! Here to help ;) Commented Nov 22, 2012 at 22:56
  • +1, you did it moments before I was to post the same reply ;) Commented Nov 22, 2012 at 23:12
  • @FalakMahmood, you have to be quick next time :P Commented Nov 23, 2012 at 19:10
3

FYI: In CAML each And (or ) conditional agregates can contain only a max of two filters. In order to have more than two you have to concatenate them as @arsalan-adam-khatri demonstrated.

1
  • this saved my life! Commented Feb 15, 2018 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.