I've a project main site and some sub sites of it. In the Main site I've list which contains URL of all sub sites. I need to create office app to retrieve the list items from all sub sites, do some calculation and store it to main site list.

Currently I'm struck with retrieving list items from all sub sites. My current code

var hostsuburl = hostUrl + "/" + oListItem.get_item('ProjectURL') + "/";
var hostsubcontext = [];
hostsubcontext.push(new SP.AppContextSite(currentcontext, hostsuburl));
var subweb = hostsubcontext.pop().get_web();
currentcontext.load(subweb, "Title");


where projectURL is the column from list(main site) which contains URL of all sub sites. But it's not returning site title. Any help would highly appreciated.

Thanks, Arun

  • Can you Please post the error which you are getting. ? – Akarsh Gupta Jan 18 '16 at 19:40
  • @AkarshGupta I'm not getting any error. I supposed to see the title of subsite, but i'm not.. I think I'm confused with Host web & App web. Is there any examples using host web&app web in SharePoint hosted app.. – Arun Jan 19 '16 at 7:34
  • do you want to get Host web details or App web details ? – Akarsh Gupta Jan 19 '16 at 8:51
  • @AkarshGupta As i'm new to this, I'm not sure which one I need. My scenario is, I should have an app which run on Root site. It retrieve & calculate data's from all available sub-site lists (Each sub-site have a list & I want to add each specific item from list then store it to root site list as cumulative from all sub-site). For this, I've list in root site, which contains url's of all sub site. I'm trying to use this list and iterate to each site & do calculation, then store it to root site list. Currently, I'm not able to load Web() for sub-site. – Arun Jan 19 '16 at 9:31
  • Are you able to get the context of the root site ? – Akarsh Gupta Jan 19 '16 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.