I just created a post about rolling up list items from multiple subsites within a site collection. In that post we took all of the titles of all the items in all the “Pages” lists in all of the subsites of the site collection. In this post we’ll add to that code, and send that resultset into an empty list (already created). We’ll cover creating the new list using SPServices and jQuery in a different post.
Here’s the order of how it happens:
- GetAllSubWebCollection (pull all sub-sites of the site collection)
- GetListCollection (pull all lists from each sub-site)
- GetListItems (pull all items from each “Pages” list)
- UpdateListItems (create new records for each item found and put them in another list)
I’m going to let the code speak for itself. As usual, check out SPServices and Mark Anderson’s blog.
$().SPServices({
operation: "GetAllSubWebCollection",
webURL: "/",
async:false,
completefunc: function(xData, Status) {
$(xData.responseXML).find("Web").each(function(){
$().SPServices({
operation: "GetListCollection",
webURL: $(this).attr("WebFullUrl"),
async:false,
completefunc: function(xData, Status) {
$(xData.responseXML).find("List").each(function(){
//function to get all items inside every list called "Pages"
if($(this).attr("Title") == "Pages") {
$().SPServices({
operation: "GetListItems",
webURL: $(this).attr("WebFullUrl"),
async: false,
listName: $(this).attr("Title"),
CAMLViewFields: "<ViewFields><FieldRef Name='EncodedAbsUrl' /><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var title = $(this).attr("ows_Title");
$().SPServices({
operation: "UpdateListItems",
async:false,
batchCmd: "New",
listName: "My new list",
valuepairs: [["Title", title]],
completefunc: function(xData, Status) {
}
})
});
}
});
}
})
}
});
})
}
})

Is there any way I can filter only to get latest SPLIST item version when I am using to get all BaseType=0 (custom lists).
Thanks in advance.
Venky
Venky,
Are you trying to get just the latest version of a single item, or the latest version of all items from a list? Can you send over the code you have so far?
Ben
Not sure who is the main target user, but normal user would not able to access this function ‘GetAllSubWebCollection’, I was stuck there.