Remove the InfoPath form customization from a SharePoint list.

Removing the InfoPath customization from a list after having used ‘Customize with InfoPath’ is not always easy, especially during a migration to SharePoint Subscription Edition. Indeed, this latest version no longer includes certain options/menus that allow you to revert to the default list forms for a content type.

To identify a list customized with InfoPath, you can use the following script (https://gist.github.com/jchable/6234bd200eae4109ac77717934d14ea0):

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
$WebAppURL="<webapp URL>"
$ReportOutput="<path to output CSV file>"
$ResultColl = @()
 
$WebsColl = Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | Get-SPWeb -Limit All
 
Foreach($Web in $WebsColl)
{
 Foreach ($List in $web.Lists | Where { 
$_.ContentTypes[0].ResourceFolder.Properties["_ipfs_infopathenabled"]})
    {
            Write-Host "InfoPath Form : $($Web.URL), $($List.Title)"
            $Result = new-object PSObject
            $Result | add-member -membertype NoteProperty -name "Site URL" -Value $web.Url
            $Result | add-member -membertype NoteProperty -name "List Name" -Value $List.Title
            $Result | add-member -membertype NoteProperty -name "List URL" -Value "$($Web.Url)/$($List.RootFolder.Url)"
            $Result | add-member -membertype NoteProperty -name "Template" -Value $list.ContentTypes[0].ResourceFolder.Properties["_ipfs_solutionName"]
            $ResultColl += $Result
    }
}

$ResultColl | Export-csv $ReportOutput -notypeinformation

Or check in SharePoint Designer to see if certain files are present:

Form customization is enabled via the _ipfs_infopathenabled property of the content type and the form URLs.

Here is a script that remove InfoPath customization from the content types of lists in a site (https://gist.github.com/jchable/26b5161dedc4bb42ab2b8bc7563e7ed0):

$web = get-spweb "<web site URL>"
  
function removeCustomInfopathListForms([String]$folderName, [Microsoft.SharePoint.SPContentType]$ct)
{
  write-host Removing custom Infopath list form on $folderName

  # Remove InfoPath customisation
  $ct.ResourceFolder.Properties["_ipfs_infopathenabled"] = "False"
  # Reset default form URL
  $ct.NewFormUrl = ""
	$ct.EditFormUrl = ""
	$ct.DisplayFormUrl = ""
  $ct.ResourceFolder.Update()     
     
	write-host "Liste:" $list.Title "  CT:" $strContentType
     
  $folder = $web.getFolder($folderName)
  write-host Delete files from folder: $folder.Name
     
  # "Delete the InfoPath Form from the server"
  for ($i = $folder.Files.count -1; $i -gt -1; $i--)
  {
       write-host deleting $folder.Files[$i].Name
       $folder.Files[$i].delete()
  }
     
  $web.dispose()
}
  
# Check content type in all lists for InfoPath forms
foreach($list in $web.Lists) { 
    foreach ($ct in $list.ContentTypes){
        if ($ct.ResourceFolder.Properties["_ipfs_infopathenabled"] -eq "True"){
            $strfolderName =$web.url + "/" + $ct.ResourceFolder.URL
            write-host "The following url is using a custom infopath list form:"  $strFolderName                               
            removeCustomInfopathListForms -folderName $strfolderName -ct $ct
        }
    }
}
$web.Dispose()

write-host "Script ended"

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur la façon dont les données de vos commentaires sont traitées.