Omicron Llama

Coding all day, every day.

0x80070057 When Changing Publishing Page Layout

I’ve been dealing with a content migration of a Publishing Site for a client, and came across an interesting error on some of the pages. The error specifically includes the above HRESULT (0x80070057), which is thrown after a call to PublishingPage.get_Layout().

It turns out that this particular page belonged on an old UAT site and was migrated (somehow) to their production site.

During this process, this broke the reference to the page layout. The Page’s internal SPListItem has a column called “PublishingPageLayout” which is of type SPFieldUrlValue. When you inspect this (via PowerShell for example) as a string it is of the format:

In our example the “yoursite” part of the URL had the web application of the old UAT server.

SharePoint is still able (somehow) to render the page fine in the browser, but if you attempt to change the layout via the browser you’ll get the above error.

Interestingly, if you attempt to access the PageLayout property of the PublishingPage object instance in C# you’ll get the same error (changing the layout access the same property in the Publishing Framework API).

The way to fix this, is to access that field value for the affect pages and to update the Url part of the reference.

I did this with simple string manipulation. Here’s a snippet of the tool I built for the client which does this (note that “item” is an SPListItem instance that represents the page being fixed):

Nice and simple!

Our issue surfaced in SharePoint 2010 but I’d safely assume that if you come across this issue in SharePoint 2013 this fix would also work.

If you’re savvy enough with PowerShell (by syntax-fu isn’t as good as C# yet) then you could easily re-write this for PowerShell and it’d still work.

As always, backup your data before you try this.


Leave a Reply

Your email address will not be published. Required fields are marked *