2

Pagination loses some of it's luster with no knowledge of the total number of results. Is it possible to perform a "row count" with either REST or SOAP (getListItems) without getting back all of the items (eg: a request truncated with $top)?

Ideally you would request /_vti_bin/listData.svc/myList?$top=2 and get back 2 results and a count of the total. Is there any at all to accomplish this is SP2010?

2

You can make a REST call like _vti_bin/Listdata.svc/YourList/$count and it should return the number of items in the list.

http://mstecharchitect.blogspot.com/2010/01/accessing-sharepoint-2010-lists-using.html

  • That is perfect. It's unfortunate that the total isn't attached to all REST calls d.__count but hey, at the cost of another call as least it's accessible. Thank you very much! – Sinetheta Jan 4 '13 at 17:25
  • 1
    Bonus points if you can tell me where something like this would be documented? Silly me, I thought I'd find an API in the MSDN, but apparently scattering tidbits across the blogosphere is the MS version of developer relations. – Sinetheta Jan 4 '13 at 18:16
  • Sadly, that link is dead or hijacked to a non useful page. :( – Joe Johnston Oct 6 '16 at 16:07
0

I know this is a very old question. But thought I would add to it with the specific syntax needed for using $count and $filter together, to achieve the total number of records based on some criteria.

In this example, I want to get the total number of Orders that were created by user ID 2:

http://yourdomain.com/sitecollection/site/_vti_bin/listdata.svc/Orders/$count/?$filter=CreatedById eq 2

Hope that helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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