Monday 27 January 2014

MissingWebPart Error in SharePoint 2010

Hi all,

Today I found useful cmdlets to diagnose and clear those errors in the Content DB of my SharePoint 2010 Farm.

How to proceed:

Step 1: Inspect the DB
-          Test-SPContentDatabase -name <ContentDB_Name> -webapplication <Web App URL>

Step 2:
-          Select the WebPart Class GUID

Step 3:
           -     Create the SQL Function and execute it into PowerShell:

function Run-SQLQuery ($SqlServer, $SqlDatabase, $SqlQuery)
{
    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "Server =" + $SqlServer + "; Database =" + $SqlDatabase + "; Integrated Security = True"
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = $SqlQuery
    $SqlCmd.Connection = $SqlConnection
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $DataSet = New-Object System.Data.DataSet
    $SqlAdapter.Fill($DataSet)
    $SqlConnection.Close()
    $DataSet.Tables[0]
}

-          Run this command with the related WebPart Class GUID:

Run-SQLQuery -SqlServer "SRV_DATABASE" -SqlDatabase "SharePoint_Content_sharepointWorkgroup17" -SqlQuery "SELECT * from AllDocs inner join AllWebParts on AllDocs.Id = AllWebParts.tp_PageUrlID where AllWebParts.tp_WebPartTypeID = '9812863c-ee62-dab6-57f5-79e9d4d36022'" | select Id, SiteId, DirName, LeafName, WebId, ListId, tp_ZoneID, tp_DisplayName | Format-List


Step 4:
-          The result will give the below info, with the URL where the Missing Web Part is located:

Id                         : a5da7b36-083f-4d07-b50b-8f1fc8d7bbe9
SiteId                   : 53061278-8b1d-4d6d-9dce-8568f90c5574
DirName              : Sites/WW12000012/Sandbox/TestWSServiceLevelDashboard
LeafName            : default.aspx
WebId                 : 2ab691b1-0d74-4bf2-9524-c6b1d969cfac
ListId                   :
tp_ZoneID           : Left
tp_DisplayName  :



                  Adding at the end of the URL "?contents=1" will let SharePoint to show the "Web Part Page"


-          So, here are the steps that I follow to remove the “ErrorWebPart”:

1- select the Error rows
2- click on “Close” to set them as “No” for the “Open on Page?” column
3- select the same Error rows then Delete them



Step 5:
-          Execute again the “Test-SPContentDatabase” to check that all entries for the MissingWebPart are gone.




That's all folks




No comments:

Post a Comment