Skip to main content

Remove Orphaned Web Parts - MissingWebPart

At some point you may have encountered an error like this while browsing through the SharePoint Health Analyzer or if you are attempting to test your content database (i.e., Test-SPContentDatabase) prior to mounting it. Message reads something like this:
One caveat is that the log message never reveals the Location of the culprit web part.  Luckily we can utilize T-SQL to query the content database and reveal the location of the web part in question.  

Query the Content Database

To do this fire up the SQL Server Management Studio either locally from your machine or while logged on to the SQL Server back-end of your SharePoint farm, open up the new Query window and enter the following statement:

USE <Content_Database_Name>
SELECT AllDocs.SiteId,WebId, Webs.Title as 'Web Title', ListId, DirName,LeafName 
FROM AllDocs 
  inner join AllWebParts on Alldocs.Id = AllWebParts.tp_PageUrlID 
inner join Webs on Alldocs.WebId = webs.Id 
WHERE AllWebParts.tp_WebPartTypeId = '7b56595c-625c-2eab-7907-8ab6f735e313'

NOTE: The text in red should be the content database name and the GUID from the error message.

Once you execute the query you should receive output similar to this:

WebID
WebTitle
List ID
Dir Name
Leaf name
b0cc8dd2-2bb9-4682-b90c-e0a043bed0e8
Knowledge Base
NULL
Corporate/KB
default.aspx

Find the URL of the Web Part Page

Given this we know that the DirName is the relative URL path of the site, and LeafName is an ASPX page where the web part is located.  From this we can construct the URL:

http://root/DirName/LeafName

which translates to something like this:

http://root/Corporate/KB/default.aspx

Delete the Web Part(s)

Now that we know the location of the web part we can finally delete the culprit web parts.  Open up the browser window and type in the URL followed by the ?contents=1 suffix.  It should look something like this:

http://root/Corporate/KB/default.aspx?contents=1

This will open up the Web Part Maintenance page which allows us to select the web parts in question and Delete them from the page.
Select the culprit web part(s) from this page and click Delete.

Check Old Versions and Recycle Bin

One more thing before we wrap it up.  Check the Recycle Bin as well as any previous Versions of the page (if Publishing is turned on).  Older versions of the page may still have the same web part(s) on them, therefore make sure you either delete those pages or remove the web parts(s) from them.  Do not forget to check the Recycle Bin for permanent deletion of those pages.

Comments

  1. There is an error in your SQL script, the correct table name is "AllWebParts". Script worked great after that fix. Thanks

    ReplyDelete
    Replies
    1. Hello John,
      Good catch, and thanks for pointing this out!
      There are also few of other SQL tables to keep an eye out for where web parts may reside (i.e., Sites, Webs). I'll update the post to reflect these changes.

      Delete
  2. In SharePoint 2013 use this:

    USE "YOUR_DATABASE_NAME"
    select DirName,LeafName from dbo.AllDocs where id in
    (select tp_PageUrlID from dbo.AllWebParts where
    (tp_WebPartTypeID='YOUR_GUID')
    )
    go

    Change:
    YOUR_DATABASE_NAME for the database you wish to query
    YOUR GUID to the GUID of the webpart that is missing, this is the number that follows:

    Message : WebPart class [THIS_NUMBER]

    You get this when you run:
    test-SPContentDatabase -name YOUR_DATABASE_NAME -WebApplication http://YOUR_SITE

    ReplyDelete
    Replies
    1. Hello Longtrail.
      I'll make a note and modify the entry.
      Thanks for the feedback.

      Delete

Post a Comment

Popular posts from this blog

SharePoint Server Search - Error Starting

Problem I recently ran into this snag at a client site while setting up the Search Service Application.  I was able to create the service application without a problem however when I attempted to start the SharePoint Server Search service (Manage services on server page) I kept getting Error Starting . After taking a peak at the logs I found the following: An attempt to start/stop instance of service SharePoint Server Search on server did not succeed. Re-run the action via UI or command line on the specified server. Additional information is below. Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) I double/triple checked the permissions and made sure that my Farm Administrator account was a member of WSS_WPG and WSS_ADMIN_WPG groups, and that those groups had full control permissions to the C:\Windows\Tasks and C:\Windows\Temp folders. Resolution I nearly lost hope when I remembered my old lost friend called STSADM.EXE. Just like in the old da...

SharePoint 2013 - Creating and Applying Composed Looks (PowerShell)

If you are a SharePoint administrator looking to quickly apply some basic branding to a site-collection in your SharePoint 2013 environment then you've come to the right spot. Before we begin I assume you have a basic understanding of what Composed Looks are, and perhaps you spent some time playing around with this concept in SharePoint 2013. If not, then don't worry.  Here is a basic primer: Composed Look is basically a package which contains elements used for controlling the overall look and feel of a SharePoint site.  This includes but not limited to Colors, Fonts, Background Image, CSS files, and Master Page files. Once created, Composed Look can be packaged by using the Design Manager feature, or we can use PowerShell to apply it across one or multiple site collections. NOTE: In this post we will be focusing on creating a composed look from an .spcolor file then using PowerShell to apply the design to a site-site collection of our choice.  We wil...

SharePoint 2013 - Can't access the site externally in Internet Explorer ("Page cannot be displayed")

Synopsis Before we start talking about the problem let's understand the setup here.  We have a SharePoint 2013 intranet site that is also configured for access outside of the corporate network.  Employees use the same URL to visit the site both internally and externally via standard ports (80 and 443). Internal URL: http://sharepoint.domain.com Public URL: https://sharepoint.domain.com The site URL has been added to the Local Intranet zone in Internet Explorer for passing domain credentials. Alternate Access Mappings have been configured in such a way that if a user requests the site over HTTP they are automatically re-directed to HTTPS. Internal URL Zone Public URL for Zone https://sharepoint.domain.com Default https://sharepoint.domain.com http://sharepoint.domain.com Default https://sharepoint.domain.com Web application has been configured to use Kerberos protocol for authenticating incom...