Javascript error in SharePoint 2010 toolbar – ‘Pub’ is undefined

This error has cropped up a few times in different sites, and is generally related to enabling and disabling the Publishing feature in SharePoint 2010 Enterprise edition. This problem manifests itself in various ways:

  1. Clicking on the Edit mini-button in the toolbar does nothing, but clicking on the Settings menu and Edit page works
  2. Clicking on the Edit mini-button may throw a javascript error “‘Pub’ is undefined”
  3. Trying to save your changes results in a correlation error:

System.ArgumentException: Invalid SPListItem. The SPListItem provided is not compatible with a Publishing Page.    at Microsoft.SharePoint.Publishing.PublishingPage.GetPublishingPage(SPListItem sourceListItem)     at Microsoft.SharePoint.Publishing.Internal.WebControls.PublishingPageStateControl.RaisePostBackEventForPageRouting(String eventArgument, SPRibbonCommandHandler control, RaisePostBackEventDelegate raisePostBackEventDelegate)     at Microsoft.SharePoint.Publishing.Internal.WebControls.PublishingPageSaveAndStopEditHandler.RaisePostBackEvent(String eventArgument)     at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

You can reproduce this error as follows:

  1. Create a web page
  2. Enable SharePoint 2010 publishing feature
  3. Edit the page
  4. Turn off sharepoint 2010 publishing feature
  5. Try to again edit the page – errors generated

When you enable sharepoint publishing it creates several task and tracking lists to support publishing workflows and additional metadata for publishing pages. Once a page is edited it inherits this metadata and links to several lists. When you then disable Publishing, you experience the issues above because:

  1. It is expecting to find workflow-related lists for publishing
  2. It is expecting to find a tab control “Pub” that is used for workflow publishing. If it can’t find the tab, you get the javascript error “Pub” not found

To resolve this issue you need to either:

  1. Re-enable the publishing feature; OR
  2. Painfully recreate your pages

I chose the path of least resistance 🙂 As long as you don’t enable publishing workflows, enabling the the Publishing features shouldn’t affect your site. As a final cautionary note, you may need to enable the Publishing feature at the Site Collection Feature level as well as the Site/subsite level! It can be enabled at the site level, but disabled at the site collection level, which again breaks the publishing process.


Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: