Juergen Riemer
Juergen Riemer

Reputation: 1473

Sharepoint: Total count of filtered list via webservices

In SharePoint 2013 I use a webservice to query a list:

System.Xml.XmlNode node = myservice.GetListItems(listName, viewName, query, viewFields, rowLimit, queryOptions, null);

I use CAML to apply filters to the default view and to limit the rows returned.

This works fine; now I want to get the total count of items with this particular filter setting how do I get this?

I know I can use GetList method but this returns me the total number of all items in the list w/o any filter applied.

Any idea to get the total count of list that is filtered via webservices?

Upvotes: 0

Views: 1772

Answers (1)

Stevangelista
Stevangelista

Reputation: 1829

SharePoint has no equivalent of a COUNT function within a query; if you want anything besides the total item count, your only option is to execute the filtered query then count the number of items returned back.

Similar question from SP2010 (unfortunately the CAML spec hasn't changed in this regard in SP2013): Determine Total Count Of Items Returned By SPQuery

Reference code from SharePoint.stackexchange: https://sharepoint.stackexchange.com/questions/26150/is-it-possible-to-return-only-the-count-of-the-query

Upvotes: 1

Related Questions