vendredi 19 décembre 2014

SharePoint 2013 getting all webs url failing in a given site collection including root web using JSOM



Using JSOM I am trying to get the collection of all the webs(sub-sites) including the root web of a given site collection and apply theme. but the url isn't correct.


Follow code:



function getWebs()
{
var context = SP.ClientContext.get_current();
var web = context.get_web();
var site = context.get_site();
var rootWeb = site.get_rootWeb();
var subWebs = rootWeb.get_webs();

context.load(subWebs, 'Include(Url, ServerRelativeUrl,ParentWeb)');
context.executeQueryAsync(
function () {
subWebs = subWebs.getEnumerator();
while(subWebs.moveNext()){
var subWeb = subWebs.get_current();
var testUrl = subWeb.get_url();
alert(testUrl);
}
},
function (sender, args) {
console.log(args.get_message());
}
);
}


Follow image from Project that have debug: debug image failed url


Correct: The expected is : http://ift.tt/1sDw1tO


Incorrect: The result is : http://ift.tt/1J963Je


And not apply theme for all subsite.



note: this method is recursive.



Some idea about how to resolve this question?








0 commentaires:

Enregistrer un commentaire