SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ...

share|improve this question
up vote 7 down vote accepted

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:

share|improve this answer
Interessting - I used the CAML Designer (, which suggested my slightly different CAML; which doesn't seem to work - at least not when using the JSOM. – nyn3x Jun 27 '12 at 11:58
Yes the JSCOM uses different format for the CAML. The Caml in my above answer should work with the JSCOM. – Vardhaman Deshpande Jun 27 '12 at 13:29
yes, it does - thx! – nyn3x Jun 28 '12 at 10:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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