SPServices GetListItems Generator Demo Page

2 minute read

Someone asked a question in the SPServices Discussions this morning because they were getting an “Object not found” error. This type of error almost always means that the references to the .js files aren’t correct for your environment. I’ve done a few posts about how to remedy this, most notably Adding jQuery to a SharePoint Page: Step One, Always  and Adding jQuery+SPServices to a SharePoint Page: Step One, Always.

But that question wasn’t the cool part (I probably get at least one “Object not found” question a day”). The cool part was alfred_j_kwack‘s original post. In it, he provided a page you can use to generated SPServices calls to GetListItems just be making some selections on the page. It’s a great little tool for someone who is just getting started with SPServices and wants to see how the calls should be assembled. I probably saw it when he first posted it about a year ago, made a note to do something with it, and then got busy.

I made some tweaks to Alfred’s code to bring it in line with the current versions of jQuery and SPServices, with a little clean up as well, and posted it on my demo site as a new demo page called GetListItemsGenerator.


The script uses WebUrlFromPageUrl, SiteDataGetListCollection, and GetList to make things work. Here’s the script, though it’s also available on the demo page.

$(document).ready(function() {

	waitMessage = "</pre>
<img style="display: block; margin-left: auto; margin-right: auto;" src="/_layouts/images/gears_an.gif" alt="" />


"; $(xData.responseXML).find("Fields > Field").each(function(index) { if((index % 6) == 0) { outputHTML += "" };outputHTML +=""; }); outputHTML += "
<td><input type="checkbox" name="" value="+ $(this).attr(" />"+ $(this).attr("DisplayName") +"</td>


';"; resultCode += "n$().SPServices({"; resultCode += "ntoperation: "GetListItems","; resultCode += "ntasync: false,"; resultCode += "ntlistName: "" + $('#ListSlct').val() + "","; resultCode += "ntwebURL: "" + $('#siteURL').text() + "","; resultCode += "ntCAMLViewFields: "" + qryCAML + "","; resultCode += "ntcompletefunc: function (xData, Status) {"; resultCode += "ntt$(xData.responseXML).SPFilterNode('z:row').each(function() {"; resultCode += "nttthtmlTable += "" + tableResult + "";"; resultCode += "ntt})"; resultCode += "ntthtmlTable += "
		resultCode += "nt}";
		resultCode += "n});";
		$('#results').html("<textarea id="resultsCode" rows="20">"+resultCode+"</textarea>");

	//load the default site


function getSiteLists(tURL){
		operation: "SiteDataGetListCollection",
		webURL: tURL,
		completefunc: function(xData, Status){
			//renderList(xData, Status)
Select a site list...
			$(xData.responseXML).find("_sList").each(function() {
" + $("Title",this).text() + "


  1. Hi Mark, I am using spservices and its great! I have one scenario where I have 15k approved or submitted items that I need to pull in a grid in a paged grid. Now the thershold 5k will error out the getitems. Can I use contentiterator along with spservice to pull the data fast with page numbers? I need great performance so I can not use simple c# based web part.

    • @Amit:

      Unfortunately, there isn’t any way around the 5k limit in SharePoint Online – yet. Apparently Microsoft is working on it. Also see this post.

      In cases like yours (I’m wrestling with one right now), I use localStorage to keep a copy of the list items, updating them whenever they change.



Have a thought or opinion?