This morning I was trying to add an OOTB lookup field to a custom list in a SharePoint sub website. I got an error of “Field type x is not installed properly. Go to the list settings page to delete this field.”
I looked through all my code and found no reference to the offending field the error was talking about. Only some random log file had info on me having used it months ago. This error didn’t happen in the root site, nor in other subweb sites. The first useful google I found was Paul Beck’s Blog . I really didn’t want to think about diving into messing with the SQL tables though. Instead I poked around in SharePoint Manager 2007(SPM) for a while looking for some explaination.
Although SPM is great for browsing–it’s like finding a needle in a haystack when looking for where a custom field type is in use. I ended up creating a Layouts page to search all the sitecollections fields to see where this offender was in use. Below is the layouts page code in case you ever need it.
If you need to decode the escaped html etc. you might use a escaped html decoder.
<%@ Assembly Name="Microsoft.SharePoint.ApplicationPages, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Page Language="C#" EnableViewState="false" EnableViewStateMac="false" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ViewHeader" src="~/_controltemplates/ViewHeader.ascx" %>
<%@ Register Tagprefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
protected void go(object sender, EventArgs args)
{
SPSite site = SPContext.Current.Site.RootWeb.Site;
using (SPWeb web = site.OpenWeb("/"))
{
//process root lists
foreach (SPList list in web.Lists)
{
processList(web, list);
}
//process root fields
if (fieldTypeInUse(web.Fields, txtFieldTypeString.Text))
{
litResults.Text += "Found in: " + web.Url.ToString() + " : SITE FIELDS<br><br>";
}
//process child webs
if (web.Webs.Count > 0)
{
for (int i = 0; i < web.Webs.Count; i++)
{
using (SPWeb subweb = web.Webs[i])
{
processWeb(subweb);
}
}
}
}
}
protected void processWeb(SPWeb web)
{
//process root lists
foreach (SPList list in web.Lists)
{
processList(web, list);
}
//process root fields
if (fieldTypeInUse(web.Fields, txtFieldTypeString.Text))
{
litResults.Text += "Found in: " + web.Url.ToString() + " : SITE FIELDS<br><br>";
}
//process child webs
if (web.Webs.Count > 0)
{
for (int i = 0; i < web.Webs.Count; i++)
{
using (SPWeb subweb = web.Webs[i])
{
processWeb(subweb);
}
}
}
}
protected void processList(SPWeb web, SPList list)
{
if (fieldTypeInUse(list.Fields, txtFieldTypeString.Text))
{
litResults.Text += "Found in: " + list.ParentWebUrl.ToString() + " : " + list.Title + "<br><br>";
}
}
public static bool fieldTypeInUse(SPFieldCollection collection, string TypeAsString)
{
foreach (SPField field in collection)
{
if (field.TypeAsString == TypeAsString)
{
return true;
}
}
return false;
}
</script>
<html><head><title>Find Rouge Field Type</title></head>
<body>
<form id="form1" runat="server">
<br />
<br />
<strong>Find Rouge Field Type</strong><br />
Fill the textbox with the name of the offending custom field.
Then click "Go" to search your entire site for any use of that field.
If you are using this then you have probably gotten an error stating that
a field is not installed correctly or something to that effect. Use the name of the field
in the error message as the text for the textbox.<br /><br />
<asp:TextBox ID="txtFieldTypeString" runat="server"></asp:TextBox>
<asp:Button ID="GoButton" runat="server" OnClick="go" Text="GO" />
<br /><br />
<strong>Results</strong>
<hr />
<asp:Literal ID="litResults" runat="server"></asp:Literal>
</form>
</body>
</html>