Say I have ten subsites, each with it's own list that use the same content type. Each list has several number columns.
I want to create a list in the parent site that provides the sum of the number columns from those lists.
Now, I know you can use a CEWP and fetch some values from other lists, but this doesn't display like a list, and doesn't do the sum.
Basically, I want a list that is a summary of all the lists (in subsites) with that content type.
How can I do this?
So, I've gotten this far using REST:
var basurl = "https://my.site.com/multisite";
GetSites();
function GetSites(){
$.ajax({
//url: baseurl + "_api/search/query?querytext='contenttype:DROID'",
url: baseurl + "_api/web/webs",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (site_data) {
var sitedata = site_data.d.results;
getSiteData(sitedata);
},
error: function (data) {
console.log("GetSites Error: "+ data);
}
});
}
//do this for each site
function getSiteData(whatdata){
$(whatdata).each(function(index,thisdata){ //splits information out of the primary array
console.log("site Url:" + thisdata.Url);
getListsbyContentType(thisdata.Url);
})
}
//gets all lists from a site
function getListsbyContentType(whatsiteurl){
$.ajax({
url: whatsiteurl + "/_api/search/query?querytext='contenttype:Item'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (listct_data) {
console.log("All CT data:" + listct_data.d.results);
$(listct_data.d.results).each(function(index,listctdata){ //splits information out of the primary array
console.log(listctdata);
});
},
error: function (data) {
console.log("getListsbyContentType Error: "+ data);
}
});
}
This will iterate through the sites okay, but it never finds my content type. Even if I change the content type from droid to ITEM it always comes up empty.