Question

I'm calling web service List.asmx using Jquery and getting results using this but its not ordering by DisplayOrder. This is the caml query.

        <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
            <soapenv:Body> \
                 <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                    <listName>Master-Footer-Links</listName> \
                    <viewFields> \
                        <ViewFields> \
                           <FieldRef Name='Title' /> \
                           <FieldRef Name='DisplayOrder' /> \
                           <FieldRef Name='Url' /> \
                       </ViewFields> \
                    </viewFields> \
                    <Query> \
                        <OrderBy><FieldRef Name='DisplayOrder' Ascending='TRUE' /></OrderBy> \
                    </Query> \
                </GetListItems> \
            </soapenv:Body> \
        </soapenv:Envelope>
Was it helpful?

Solution

You need to wrap your Query node inside a query node so that it looks like this:

<query>
  <Query>
    <OrderBy><FieldRef Name='DisplayOrder' Ascending='TRUE' /></OrderBy>
  </Query>
</query>

OTHER TIPS

It sounds like your DisplayOrder column type is set to contain strings or text instead of numbers. If you open the list and navigate to Settings -> List Settings then scroll down to Columns, what is the type next to DisplayOrder? If it is "single line of text" or some other string type you can switch the type. Click the name of your column and change the type to "Number (1, 10, 100)" and click OK. You will receive a message about possible loss of data (make sure to have a backup of your list first if this is important data) and click OK on the popup. When you query your list now you should receive numerical sorting instead of alphabetical.

I found this info from this url.

Hopefully you will resolve your issue by this.

Thanks,

Ashish Chotalia

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top