SharePoint CAML OrderBy Modified does not work

brysseldorf picture brysseldorf · Oct 20, 2009 · Viewed 9.1k times · Source

I have made a query against a list. I want to get the last modified item which meets a certain condition, and my query looks like this:

<Query><OrderBy><FieldRef  Name='Modified' Ascending='FALSE' /></OrderBy><Where><Eq><FieldRef Name='kortnummer'/><Value Type='String'>kv11</Value></Eq></Where></Query>

I get the listitems i need, just not in the right order. Changing Ascending to true does nothing, so obviously there is something with the OrderBy clause that is not right..

According to MSDN it should be possible to order by Modified.

Any idea why my OrderBy does not work?

Answer

Filip Lindboe picture Filip Lindboe · Oct 21, 2009

I always put the OrderBy after the Where.

Otherwise you could make sure that you are using the internal name. I usually use SharePoint Manager 2007 to get the internal field names. Codeplex SharePoint manager

I can see that on a list in my SharePoint, the modified column internal name is "Last_x0020_Modified".