1

How do I build a CAML query for this condition,

Status = "Current" (or) Status = "Outgoing" (and) Log Status = "Not Submitted"

@"<where><And><Or><Eq><FieldRef Name='Status'/><Value Type='Choice'>Current</Value></Eq><Eq><FieldRef Name='Status' /><Value Type='Choice'>Outgoing</Value></Eq></Or><Eq><FieldRef Name='CYQ1' /> <Value Type='Text'>Not Submitted</Value></Eq></And></where>"

This doesnt seem to work. Please advice.

0

Try this

@"<Where>" +
    "<And>" +
        "<Or>" +
            "<Contains><FieldRef Name=""Status""></FieldRef><Value Type=""Choice"">Current</Value></Contains>" +
            "<Contains><FieldRef Name=""Status""></FieldRef><Value Type=""Choice"">Outgoing</Value></Contains>" +
        "</Or>" +
        "<Eq>" +
            "<FieldRef Name='CYQ1' /><Value Type='Text'>Not Submitted</Value>" +
        "</Eq>" +
    "</And>" +
"</Where>";

I have tested below using CAML Query Builder and it worked

<Where>
  <And>
    <Or>
       <Contains><FieldRef Name="Status" /><Value Type="Choice">Outgoing</Value></Contains>
       <Contains><FieldRef Name="Status" /><Value Type="Choice">Current</Value></Contains>
    </Or>
    <Eq>
      <FieldRef Name="CYQ1" /><Value Type="Text">Not Submitted</Value>
    </Eq>
  </And>
</Where>
  • It dint work Amal, I replaced <eq> with <Contains> like you did but all the items are being returned – user25284 Oct 30 '14 at 19:10
  • Can you update the question with complete code. How you are executing the CAML Query etc. – Amal Hashim Oct 30 '14 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy