I need to go through all sites belonging a site collection to validate a property bag of them. following is my code. the problem is the second call to get the property uses only one of the sites. I thought it maybe go through sites one by one and get the property bag, but it doesn't. it gets property bag of only one of sites, I think it is the last one.
RootContext = new SP.ClientContext(RootSiteUrl);
SubSites = RootContext.get_web().get_webs();
RootContext.load(SubSites);
RootContext.executeQueryAsync(
Function.createDelegate(this, function (sender, args) {
var subSiteEnum = SubSites.getEnumerator();
while (subSiteEnum.moveNext()) {
var Site = subSiteEnum.get_current();
var SiteContext = new SP.ClientContext(Site.get_url());
var allProperties = SiteContext.get_web().get_allProperties();
SiteContext.load(allProperties);
SiteContext.executeQueryAsync(
Function.createDelegate(this, function (sender, args) {
var Prop = allProperties.get_fieldValues()["myProp"];
alert(Site.get_title());
if (Prop != undefined) {
alert(Prop);
}
}),
Function.createDelegate(this, function (sender, args) {
alert('Misslyckades med att hämta property bags för ' + Site.get_title() + ' error: ' + args.get_message());
})
);
}
}),
Function.createDelegate(this, function (sender, args) {
alert('Misslyckades med att hämta subsiter för s: ' + args.get_message());
})
);