Question

I am not sure if this is the correct way of defining two orderby's in the query as I could not find the documentation regarding this issue. Nor did this work as expected for me.

I am trying this:

 var query = "<Query><OrderBy><FieldRef Name='Number' Ascending='true' /><FieldRef Name='Number' Ascending='true' /></OrderBy></Query>";
Was it helpful?

Solution

A quick search took me to this page: OrderBy Element (Query)

<OrderBy>
  <FieldRef Name="Newcomers"/>
  <FieldRef Name="Years" Ascending="FALSE"/>
  <FieldRef Name="Location"/>
</OrderBy>

All I can say is that you're doing what the documentation shows. Have a poke around over there yourself - I can safely say you have more experience than I do with SharePoint Services.

Edit: I doubt this makes a difference, but try defining your query like this:

var query = '<Query><OrderBy><FieldRef Name="Number" Ascending="TRUE" /><FieldRef Name="Number" Ascending="TRUE" /></OrderBy></Query>';

I just swapped the apostrophe string declaration around to use double quotes, and the case of true to TRUE.

OTHER TIPS

You can use U2U to build all the CAML for you. I use it for all my SharePoint query building for free.

http://www.u2u.be/res/tools/camlquerybuilder.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top