I have the following JSOM code:

var query = "<View><Query><Where><Eq><FieldRef Name='Category'/><Value Type='Choice'>ValueA</Value></Eq></Where></Query><ViewFields><FieldRef Name='Title'/><FieldRef Name='Value'/><FieldRef Name='Created'/></ViewFields><OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy><QueryOptions><RowLimit>6</RowLimit></QueryOptions></View>"
camlQuery = new SP.CamlQuery()
items = list.getItems(camlQuery)

however the items returned don't seem to be in the order I set ...

1 Answer 1


The method of setting the query options is a little different in the Client Object Model. The correct form of your query is:

                <FieldRef Name='Category'/>
                <Value Type='Choice'>ValueA</Value>
            <FieldRef Name='Created' Ascending='FALSE' />
        <FieldRef Name='Title'/>
        <FieldRef Name='Value'/>
        <FieldRef Name='Created'/>

See this for more details: CAML and the Client Object Model.

  • Interessting - I used the CAML Designer (karinebosch.wordpress.com/2012/05/12/caml-designer), which suggested my slightly different CAML; which doesn't seem to work - at least not when using the JSOM.
    – nyn3x
    Commented Jun 27, 2012 at 11:58
  • Yes the JSCOM uses different format for the CAML. The Caml in my above answer should work with the JSCOM. Commented Jun 27, 2012 at 13:29
  • yes, it does - thx!
    – nyn3x
    Commented Jun 28, 2012 at 10:28

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.