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

CAML makes me sad some days. Can someone point me in the right direction for the syntax in regards to a CAML query that would evaluate where X= A&B&C&D. My nesting is all off i'm assuming.

<Where>
<And>
<Eq><FieldRef Name="Status" /><Value Type="Text">A</Value></Eq>
<Eq><FieldRef Name="Region" /><Value Type="Text">B</Value></Eq>
<And>
<Eq><FieldRef Name="BagVal" /><Value Type="Text">C</Value></Eq>
<Eq><FieldRef Name="SumVal" /><Value Type="Text">D</Value></Eq>
</And>
</And>
</Where>
share|improve this question
    
For future reference, you can use a tool like CAML Query builder (codeproject.com/Articles/458008/CAML-Query-Builder) to build error-prone CAML queries. –  Will Au Mar 21 '13 at 2:37
add comment

1 Answer 1

up vote 6 down vote accepted

Yes, it's your nesting. Try this:

<Where>
  <And>
    <Eq><FieldRef Name="Status" /><Value Type="Text">A</Value></Eq>
    <And>
      <Eq><FieldRef Name="Region" /><Value Type="Text">B</Value></Eq>
      <And>
        <Eq><FieldRef Name="BagVal" /><Value Type="Text">C</Value></Eq>
        <Eq><FieldRef Name="SumVal" /><Value Type="Text">D</Value></Eq>
      </And>
    </And>
  </And>
</Where>

You are not allowed to put more than two conditions in a single condition group.

share|improve this answer
    
Thanks Danny. It's much appreciated. –  E7AD Mar 25 '13 at 17:37
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.