0

I am currently making a call to GetListItems and I'm curious if there is any way to both page results and get the total number of records available?

Here is what I am passing in my call to lists.asmx:

var xmlData = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
                       "<soap:Body>" +
                        "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
                            "<listName>Planning Road Names</listName>" +
                            "<query>" +
                                "<Query xmlns=''>" +
                                    "<OrderBy>" +
                                        "<FieldRef Name='Title' />" +
                                    "</OrderBy>" +
                                "</Query>" +
                            "</query>" +
                            "<viewFields>" +
                                "<ViewFields xmlns=''  />" +
                            "</viewFields>" +
                            "<queryOptions>" +
                                "<QueryOptions xmlns='' />" +
                            "</queryOptions>" +
                        "</GetListItems>" +
                      "</soap:Body>" +
                    "</soap:Envelope>";

I looked on the documentation page and it sounds like the web service will automatically page the results for you:

Paging - A string that contains data needed to support paging, including a ListItemCollectionPositionNext attribute. If left empty, the list items returned start from the beginning of the list. Client applications should supply the value of a server-supplied bookmark. The server returns the next page of data based on the bookmark supplied. This element is optional, and its default value is an empty string.

But I can't find a way to get the total number of records available. Can this be done?

2 Answers 2

0

This question has been repeated several times at several places and the answer is there is no straightforward way to figure out how many total records are available and hence figure out how many pages in total. the most educated guess is that this is due to performance reasons.

Check out this thread (I am sure you can find many others): https://stackoverflow.com/questions/4031998/determine-total-count-of-items-returned-by-spquery

0

Use SVC to get count

https://<site>.com/<subsites>/_vti_bin/ListData.svc/<ListTitle>/$count

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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