Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PatD/f62cdf4863e5b5577a8c to your computer and use it in GitHub Desktop.
Save PatD/f62cdf4863e5b5577a8c to your computer and use it in GitHub Desktop.
SharePoint 2010 - SP Services - get list item counts in a collection
// Assumes jQuery and SP Services
// Outputs all lists and their item count
// From @sympmarc http://sympmarc.com/2010/09/19/down-and-dirty-spservices-solution-to-solve-an-emergency-request/
$(document).ready(function() {
$().SPServices({
operation: "GetAllSubWebCollection",
async: true,
completefunc: function (xData, Status) {
$(xData.responseXML).find("Web").each(function() {
var thisUrl = $(this).attr("Url");
$().SPServices({
operation: "GetListCollection",
webURL: thisUrl,
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).find("List").each(function() {
console.log("Site:" + thisUrl + " List:" + $(this).attr("Title") + " ItemCount:" + $(this).attr("ItemCount"));
});
}
});
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment