Tracking down issue with Custom Field in Sharepoint

A long time ago when SharePoint was first deployed, the contractors we worked with deployed a custom field through a wsp solution. FilteredLookupField it’s a variation of https://sp2013filteredlookup.codeplex.com/ which made matters worst when I tried to locate a copy of the solution to deploy onto our other environments, it simply wasn’t possible. Fast forward to this year, we’ve been faced with issues restoring the site and this field was only complicating matters. I’m more comfortable with SharePoint’s CSOM/Rest API these days that I am now ready to dump this custom field for a standard text string that is out-of-the-box and inject the necessary JavaScript UI targeting the field I’m interested in. If it breaks, it’s just UI, all my upgrade woes and field changes are no longer tied to the wsp framework which offers little benefit to me other than potentially adding server side validation logic which I can provide workarounds through workflows.

Here is a copy and paste of a powershell script to cycle through your list and probe those broken fields.

If you see GREEN, you’re clean
If you see RED, you’re dead

Example of RED error:

Field type FilteredLookupField is not installed properly. Go to the list 
settings page to delete this field. 
At line:39 char:13

Powershell script below:

Add-PSSnapin Microsoft.SharePoint.PowerShell

$site = "http://SERVER/sites/SITENAME";

$spWeb = Get-SPWeb $site;
$spSite = Get-SPSite $site;

function CheckFieldOccurences($webUrl, $fieldInternalName) 
{  
  $rootweb = Get-SPWeb $webUrl
  $fld = $rootweb.Fields.GetFieldByInternalName($fieldInternalName)
  CheckFieldOccurencesRecursive $rootweb $fld
}

function CheckFieldOccurencesRecursive($web, $fld)
{  
  $webUrl = $web.Url
  Write-Host "- WEB >> $webUrl" -ForegroundColor Green  
  foreach($list in $web.Lists)  
  {   
    $listTitle = $list.Title
    if ($list.ContentTypesEnabled)   
    {    
      Write-Host "-- LIST >> $listTitle" -ForegroundColor Green    
      $cts = $list.ContentTypes    
      foreach($ct in $cts)    
      {     
        $ctname = $ct.Name     
        Write-Host "--- CONTENT TYPE >> $ctname" -ForegroundColor Green     
        foreach($fl in $ct.FieldLinks)     
        {      
          if ($fl.Id -eq $fld.Id)      
          {              
            write-host "!!! Found occurence in Content Type >> $ctname" -ForegroundColor Red      
          }     
        }    
      }   
    }
    foreach($listFld in $list.Fields)
    {
      if ($listFld.InternalName -eq $fld.InternalName)
      {
        write-host "!!! Found occurence in List >> $listTitle" -ForegroundColor Red
      }
    }
  }  
  foreach($subWeb in $web.Webs)  
  {   
    CheckFieldOccurencesRecursive $subWeb $fld
  } 
}

cls

$fieldInternalName = "FilteredLookupField"

CheckFieldOccurences $site $fieldInternalName