Search code examples
sharepointsharepoint-2007caml

SharePoint CAML query Orderby does not support descending attribute.?


Trying to fetch data from SharePoint List using CAML query.

Am using the attribute Descending, but does not work as expected.

Please find the code below.

<OrderBy>
    <FieldRef Name='ID' Descending = 'True'/>
</OrderBy>

Above code still fetches the smallest ID(where ID is 1,2,3..so on), in my case it fetches the ID=1

Thanks in advance.


Solution

  • AFAIK, there is no "Descending" attribute for specifying a descending order by.

    Instead, you must use the Ascending attribute, and specify "false" as the value.

    <OrderBy>
        <FieldRef Name='ID' Ascending='FALSE'/>
    </OrderBy>
    

    As you can see from this page

    Ascending -- Optional Boolean. This specifies the sort order on a FieldRef element that is defined in a view. The default value is TRUE.