0

I want to get all the items from my list, like this (A&B) AND (C&D), but my CAMLquery doesn't seem to work, here is what I've tried so far:

var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml( "<View>" + "<Query>" + "<Where>" + "<And>" + "<And>" + "<Eq><FieldRef Name='Prioritet'/><Value Type='Text'>A</Value></Eq>" + "<Eq><FieldRef Name='Status'/><Value Type='Text'>B</Value></Eq>" + "</And>" + "<And>" + "<Eq><FieldRef Name='Prioritet'/><Value Type='Text'>C</Value></Eq>" + "<Eq><FieldRef Name='Status'/><Value Type='Text'>D</Value></Eq>" + "</And>" + "</And>" + "</Where>" + "</Query>" + "</View>");

2
  • 1
    This won't work since this CAML query is checking if the column Prioritet and Status have 2 different values in an item i.e. it's checking if Prioritet has values A and C for the same item which is impossible. I'd suggest reformulating your query. Commented Aug 10, 2015 at 14:36
  • as say @uberz91, this should be Or instead an AND For example: <Or><And></And><And></And></Or> Commented Aug 10, 2015 at 14:49

1 Answer 1

-1

the syntax is each < and> statement content 2 queries.

section <and> is one query in another <and> statement

change the query to:

"<View>" +
  "<Query>" +
    "<Where>" +
        "<And>" +
            "<And>" +
                "<And>" + <------first
                    "<Eq><FieldRef Name='Prioritet'/><Value Type='Text'>A</Value></Eq>" + <----- 1
                    "<Eq><FieldRef Name='Status'/><Value Type='Text'>B</Value></Eq>" + <------2
                "</And>" +
                "<Eq><FieldRef Name='Prioritet'/><Value Type='Text'>C</Value></Eq>" + <----- second
            "</And>" +
            "<Eq><FieldRef Name='Status'/><Value Type='Text'>D</Value></Eq>" +
        "</And>" +
    "</Where>" +
  "</Query>" +
"</View>"
1
  • The query syntax is correct. Main <And> contains two child <And> tags, and both child tags contain two <Eq> tags. Only problem is in contradictory conditions which your answer doesn't fix. Commented Jul 27, 2016 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.