Search code examples
sharepoint-2010camlspservices

CAML Query with Nested OR's and AND's using SPServices


I have used this post a reference CAML query with nested AND's and OR's for multiple fields. The difference for mine is I do not need AND's with nested OR's inside of them.

I have the nested OR's working by themselves, however I need to add in three AND conditions. I'm not quite sure how to do this with the nested OR's .

My goal is as follows with a sample code included below. Test-1 is equal to A or B or C and Test-2 is equal to D and Test-3 is equal to E and Test-4 is equal to F.

<Where>
    <And>
        <Or>
            <Eq>
                <FieldRef Name='Test-1' />
                <Value Type='Text'>A</Value>
            </Eq>
                <Or>
                    <Eq>
                        <FieldRef Name='Test-1' />
                        <Value Type='Text'>B</Value>
                    </Eq>
                    <Eq>
                        <FieldRef Name='Test-1' />
                        <Value Type='Text'>C</Value>
                    </Eq>
                </Or>
        </Or>
        <And>
            <Eq>
                <FieldRef Name='Test-2' />
                <Value Type='Text'>D</Value>
            </Eq>
            <Eq>
                <FieldRef Name='Test-3' />
                <Value Type='Text'>E</Value>
            </Eq>
            <Eq>
                <FieldRef Name='Test-4' />
                <Value Type='Text'>F</Value>
            </Eq>
        </And>
    </And>
</Where>

Thanks for the help


Solution

  • Using U2U instead of another piece of software I was able to solve my problem by removing and moving the AND.