jeudi 19 mars 2015

Setting Masterpage and Theme in the same Web iteration



I have an interesting issue within a Branding Feature. I'm iterating through all Webs and setting the Theme and the MasterPage.


Setting the master page works by itself:



foreach(SPWeb web in site.AllWebs)
{
web.MasterUrl = masterUrl;
web.Update();
}


Setting the theme also works by itself:



foreach(SPWeb web in site.AllWebs)
{
web.ApplyTheme(themeUrl, "", "", true);
}


But together it throws the error (on web.update()) "the web being updated was changed by an external process."



foreach(SPWeb web in site.AllWebs)
{
web.ApplyTheme(themeUrl, "", "", true);
web.MasterUrl = masterUrl;
web.Update();
}







0 commentaires:

Enregistrer un commentaire