0

The CAML query below didn't work for me. Any help?

$viewQuery = "<Where><And><Eq><FieldRef Name='PP'/><Value Type='Integer'><UserID Type='Integer'/></Value></Eq><And><Eq><FieldRef Name='Org' /><Value Type='Choice'>Rules</Value></Eq><Eq><FieldRef Name='Completed' /><Value Type='Boolean'>0</Value></Eq></And><And><Geq><FieldRef Name='Created' /><Value IncludeTimeValue='FALSE' Type='DateTime'>$FDate</Value></Geq><Leq><FieldRef Name='Created' /><Value IncludeTimeValue='FALSE' Type='DateTime'>$ToDate</Value></Leq></And></And></Where>";

The above query works fine if I remove the first condition. when I add the fifth 'And' condition it is throwing error.

PS: I cant install a CAML query builder.

1 Answer 1

1

Try your CAML query in below format:

<Where>
    <And>
        <Eq><FieldRef Name='PP'/><Value Type='Integer'><UserID Type='Integer'/></Value></Eq>
        <And>
            <Eq><FieldRef Name='Org' /><Value Type='Choice'>Rules</Value></Eq>
            <And>
                <Eq><FieldRef Name='Completed' /><Value Type='Boolean'>0</Value></Eq>
                <And>
                    <Geq><FieldRef Name='Created' /><Value IncludeTimeValue='FALSE' Type='DateTime'>$FDate</Value></Geq>
                    <Leq><FieldRef Name='Created' /><Value IncludeTimeValue='FALSE' Type='DateTime'>$ToDate</Value></Leq>
                </And>
            </And>
        </And>
    </And>
</Where>

Similar thread: How to write CAML Query with more than 3 AND Condition

1
  • 1
    That worked. Thanks.
    – Venkat
    Dec 8, 2021 at 14:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.