SharePoint version history not working

This is the solution I have got from Microsoft Support to resolve version history not working on a specific list, on a specific site collection. This solution recrate corrupted forms for the given list. (use by your own discretion – good idea to backup first)

# this script fixes any corrupted forms on a given list on a given site collection

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$web = Get-SPWeb [yourdomain/sitecollection]
$list = $web.Lists[ListNAME']
#Fixing Upload.aspx
$NewForm = $web.GetFile($list.RootFolder.SubFolders['Forms'].Files['Upload.aspx'].ServerRelativeUrl)
$WebpartManager = $NewForm.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$ListFormWP = $WebpartManager.WebParts[0]
if ( $ListFormWP -ne $null ) { $WebpartManager.DeleteWebPart($ListFormWP)}
$NewListFormWP = New-Object Microsoft.SharePoint.WebPartPages.ListFormWebPart
$NewListFormWP.ListId = $list.ID
$NewListFormWP.FormType = [Microsoft.SharePoint.PAGETYPE]::PAGE_NEWFORM
$WebpartManager.AddWebPart($NewListFormWP,"Main", 1)
#Fixing EditForm.aspx
$EditForm = $web.GetFile($list.RootFolder.SubFolders['Forms'].Files['Dispform.aspx'].ServerRelativeUrl)
$WebpartManager = $EditForm.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$ListFormWP = $WebpartManager.WebParts[0]
if ( $ListFormWP -ne $null ) { $WebpartManager.DeleteWebPart($ListFormWP)}
$NewListFormWP = New-Object Microsoft.SharePoint.WebPartPages.ListFormWebPart
$NewListFormWP.ListId = $list.ID
$NewListFormWP.FormType = [Microsoft.SharePoint.PAGETYPE]::PAGE_DISPLAYFORM
$WebpartManager.AddWebPart($NewListFormWP,"Main", 1)
#Fixing DispForm.aspx
$ViewForm = $web.GetFile($list.RootFolder.SubFolders['Forms'].Files['EditForm.aspx'].ServerRelativeUrl)
$WebpartManager = $ViewForm.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$ListFormWP = $WebpartManager.WebParts[0]
if ( $ListFormWP -ne $null ) { $WebpartManager.DeleteWebPart($ListFormWP)}
$NewListFormWP = New-Object Microsoft.SharePoint.WebPartPages.ListFormWebPart
$NewListFormWP.ListId = $list.ID
$NewListFormWP.FormType = [Microsoft.SharePoint.PAGETYPE]::PAGE_EDITFORM
$WebpartManager.AddWebPart($NewListFormWP,"Main", 1)

$list.DefaultNewFormUrl = $list.RootFolder.SubFolders['Forms'].Files['Upload.aspx'].ServerRelativeUrl
$list.DefaultDisplayFormUrl = $list.RootFolder.SubFolders['Forms'].Files['Dispform.aspx'].ServerRelativeUrl
$list.DefaultEditFormUrl = $list.RootFolder.SubFolders['Forms'].Files['EditForm.aspx'].ServerRelativeUrl
$list.update() 

Leave a Reply

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