0

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();
}
1

So apparently, .Update() is called from within ApplyTheme(...)

While that takes a couple seconds, any subsequent update will fail with the above error. To solve, simply set the master page first:

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.