SharePoint 2010 : Templates and Document Information Panel Errors

Came across an issue when centralising some documentation where sites created from a template would display erors when creating new documents:

“The Document Information Panel was unable to load. The document will continue to load. For more information, contact your system administrator.”

“The form cannot be opened. To fix this problem, contact the form designer. Form template: http://<site address>/../proppanel.xsn. The XML Schema for the form template has an invalid value for the following attribute: location.” 

 

I came across the following resource thaty got me started, but there were a couple of issues – typo in the script for third tier sub sites meant the script failed, the script was long winded. Below I have detailed a modified script which addresses the typo, and length issue to some degree. Be sure to set the correct URL befor executing, as well as changing the Document Library name – mine were called “Project Documentation.”

{code lang:css showtitle:false lines:false hidden:false}function Fix-List($list)
{
Write-Host $list.Title
$fields = $list.fields
foreach($field in $fields)
{
if($field.SourceId -eq ‘{$ListId:Project Documentation;}’)

$schemaxml = $field.SchemaXML
$schemaxmldata = [xml]$schemaxml
$schemaxmldata.Field.SetAttribute(“SourceID”, $list.ID)
$schemaxml = $schemaxmldata.get_InnerXml()
$field.SchemaXML = $schemaxml
$field.Update()
Write-Host “Fixed” $field.Title “field”
}
}
        }

function Apply-Fix($siteUrl)
{
clear
Add-PSSnapin “Microsoft.SharePoint.Powershell” -ErrorAction SilentlyContinue # -EA 0
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
foreach ($spwTarget1 in (Get-SPSite $siteUrl).RootWeb.Webs)
{
        Write-Host “Checking Web: ” $spwTarget1.Url
        foreach($list in $spwTarget1.Lists)
            {
            Fix-List($list)
            }
     # Sub-sites, first level        
foreach ($spwTarget2 in $spwTarget1.Webs)
{
Write-Host “Checking Web: ” $spwTarget2.Url
     foreach($list in $spwTarget2.Lists)
{
         Fix-List($list)
        }
     # Sub-sites, second level
foreach ($spwTarget3 in $spwTarget2.Webs)
{
Write-Host “Checking Web: ” $spwTarget3.Url
foreach($list in $spwTarget3.Lists)
{
         Fix-List($list)
         }
     # Sub-sites, third level
         foreach ($spwTarget4 in $spwTarget3.Webs)
{
Write-Host “Checking Web: ” $spwTarget4.Url
foreach($list in $spwTarget4.Lists)
{
         Fix-List($list)
         }
}
}
}
}
Write-Host “Done.”
}
Apply-Fix -siteUrl “https://<site collection URL>”{/code}