Friday, 25 November 2016

SpQuery : [Error] Cannot complete this action : How to add three condition in where clause?

Multiple AND nested SPQuery (CAML):

Example 1

<Where>
      <And>
         <And>
            <Eq>
               <FieldRef Name='EmployeeID' />
               <Value Type='Text'>12345</Value>
            </Eq>
            <Eq>
               <FieldRef Name='Status' />
               <Value Type='Text'>Active</Value>
            </Eq>
         </And>
         <Eq>
            <FieldRef Name='Gender' />
            <Value Type='Text'>F</Value>
         </Eq>
      </And>
   </Where>



Example 2

<And>
    <Eq>... condition...</Eq>
    <And>
        <Eq>... condition...</Eq>
        <And>
            <Eq>... condition...</Eq>
            <And>
                <Eq>... condition...</Eq>
                <Eq>... condition...</Eq>
            </And>
        </And>
    </And>
</And>


Reference: https://docs.microsoft.com/en-us/sharepoint/dev/schema/and-element-query

No comments:

Post a Comment