1

I want to create a CAML Query like this

(status= waiting for approval && Requestor Manager = UserID)or(status= stage2 && Approver= UserID)

Please let me know what i am wrong here

 <Where>
  <And>
     <Or>
        <And>
           <Eq>
              <FieldRef Name='RequetorsManager' />
              <Value Type='Integer'>
                 <UserID />
              </Value>
           </Eq>
           <Eq>
              <FieldRef Name='Status' />
              <Value Type='Choice'>Waiting For Approval</Value>
           </Eq>
        </And>
        <Eq>
           <FieldRef Name='Approver' />
           <Value Type='Integer'>
              <UserID />
           </Value>
        </Eq>
     </Or>
     <Eq>
        <FieldRef Name='Status' />
        <Value Type='Choice'>Stage2</Value>
     </Eq>
  </And>
</Where>
1
  • 2
    You might want to download a tool like U2U CAML Query Builder to help you write it. I find it very confusing to write queries when you want to make a "this + that OR another thing + yet somethin else" statements.
    – Morten K
    Commented Dec 6, 2017 at 16:54

1 Answer 1

1

Try the below CAML Query

   <Where>
      <Or>
         <And>
            <Eq>
               <FieldRef Name='status' />
               <Value Type='Choice'>waiting for approval</Value>
            </Eq>
            <Eq>
               <FieldRef Name='Requestor Manager' />
               <Value Type='Integer'>1</Value>
            </Eq>
         </And>
         <And>
            <Eq>
               <FieldRef Name='status' />
               <Value Type='Choice'>Stage2</Value>
            </Eq>
            <Eq>
               <FieldRef Name='Approver' />
               <Value Type='Integer'>2</Value>
            </Eq>
         </And>
      </Or>
   </Where>

Note: You can use U2U tool to build your CAML Query based on your requirements, to download the tool check U2U tool

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.