Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted
<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!

share|improve this answer
    
Thanks for this Arsalan. I actually came to the same conclusion minutes after I posted this query. Thanks very much. –  E7AD Nov 22 '12 at 22:53
    
No problem! Here to help ;) –  Arsalan Adam Khatri Nov 22 '12 at 22:56
    
+1, you did it moments before I was to post the same reply ;) –  Falak Mahmood Nov 22 '12 at 23:12
    
@FalakMahmood, you have to be quick next time :P –  Arsalan Adam Khatri Nov 23 '12 at 19:10
add comment

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.

share|improve this answer
add comment

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.