May 18, 2012

SharePoint 2010 Error: This item is no longer available. It may have been deleted by another user.

We have upgraded a few custom sites with custom list definitions from MOSS 2007 to SharePoint 2010, and had the following error in some of the lists that got migrated:

image

Error

This item is no longer available.  It may have been deleted by another user.  Click 'OK' to refresh the page.

But wait: I am looking at the item, I hit refresh 20 times and the item is still there, are you kidding me!

Solution

Note: I am not responsible for any damages caused by the following solution, make sure your environment is backed up and ready for restore in case you need it.

A while back, I heard stuff about ListView webpart being carried over from the upgrade and was causing issues (since its not the XSLT List viewer). I decided to crank open my Microsoft SQL Server Management Studio and started looking at my content database AllWebParts  table and found out that the webpart type ID for the lists that are working are not the same as the ones that are broken for the views pages.

Working tp_WebPartTypeId = 874F5460-71F9-FECC-E894-E7E858D9713E

Broken tp_WebPartTypeId = BAF5274E-A800-8DC3-96D0-0003D9405663 or BAF5274E-A800-8DC3-96D0-0003D9405663

So I crossed my fingers, created a backup of the content database and ran a SQL script to update the value to the working one, and all of a sudden, ITS WORKING!!!
Here is the script I ran:

UPDATE AllWebParts
  SET tp_WebPartTypeId = '874F5460-71F9-FECC-E894-E7E858D9713E'
  WHERE tp_WebPartTypeId IN('BAF5274E-A800-8DC3-96D0-0003D9405663','2242CCE6-491A-657A-C8EE-B10A2A993EDA') AND
  tp_DisplayName <> '' AND
  tp_ListId IN(select tp_ID FROM ALLLists where tp_title IN('List 1', 
                                                            'List 2'))

Happy coding.


Update (8/14/2012)


One of my colleagues found out that this also fixes the missing “Add new Item” link at the bottom of your list views, so there is another benefit for you.


Update (8/16/2012)


I have created a PowerShell script that will do the job automatically without the need to open up SQL Management Studio:



# Created by Dennis Alzoubi    
# Version 1.0
# Last Updated 9/26/2012 8:03 am
# Purpose: Updates the list views after SharePoint 2007 to 2010 Upgrade to Xslt Views
param([Parameter(Position=0, Mandatory=$true, HelpMessage="Url of the SharePoint site")][string]$siteUrl,
      [Parameter(Position=1, Mandatory=$true, HelpMessage="Title of the list")][string]$listTitle)
      
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
    Write-Host 'Reading in SharePoint SnapIn'
    Add-PsSnapin Microsoft.SharePoint.PowerShell;
}
 
 
#Load the assemblies required for the SQL database rename.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") 
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended")
 
#Method that renames the Database in SQL
function UpdateListViews($dbServerName, $databaseName)
{
    try
    {
        Write-Host "Getting SQL server information" -ForegroundColor Yellow
        $srv = new-Object Microsoft.SqlServer.Management.Smo.Server($dbServerName)
        Write-Host "Getting content database information" -ForegroundColor Yellow
        $db = $srv.Databases.Item($databaseName)
        
        $web = Get-SPWeb $siteUrl
        $listId = $web.Lists[$listTitle].Id
        
        $updateTsql = "UPDATE AllWebParts `
                        SET tp_WebPartTypeId = '874F5460-71F9-FECC-E894-E7E858D9713E' `
                        WHERE tp_WebPartTypeId IN('BAF5274E-A800-8DC3-96D0-0003D9405663','2242CCE6-491A-657A-C8EE-B10A2A993EDA') `
                        AND tp_DisplayName <> '' `
                        AND tp_ListId ='$listId'"
        
        Write-Host "Executing update Query. Query: "$updateTsql -ForegroundColor Yellow
        $db.ExecuteNonQuery($updateTsql)
    }
    catch
    {
        Write-Error "Error in 'UpdateListViews'"
        Write-Error $_.Exception.Message
    }
    finally
    {
        $web.Dispose()
    }
}
 
try
{
    Write-Host "Getting SharePoint site information for: "$siteUrl -ForegroundColor Yellow
    $site = Get-SPSite $siteUrl
    
    Write-Host "Content database information" -ForegroundColor Yellow
    $contentDB = $site.ContentDatabase.Name
    Write-Host "Content database server information" -ForegroundColor Yellow
    $dbServer = $site.ContentDatabase.Server
    
    Write-host Updating List Views for List: $ListTitle. DBServer: $dbServer. ContentDB: $contentDB. -ForegroundColor Yellow
    UpdateListViews $dbServer $contentDB
}
catch
{
    Write-Error "Error in 'Process'"
    Write-Error $_.Exception.Message
}
finally
{
    $site.Dispose()
    Write-Host "Press any key to continue ..."
    $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}

2 comments:

  1. Wow this actually works. Migrated from 2007, one of the document libraries showed this behaviour. Found the list and run ur update command on it. The result is a perfect working ECB... creepy but Hey it is sharepoint...
    Thnx alot

    ReplyDelete