Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a custom list, and I've added a 'Page Image' field by clicking on the 'Add from existing site columns' link on the Settings page for the list. I would now like to remove the field, but clicking on the field name on the Settings page yields no 'Delete' functionality.

share|improve this question
add comment

5 Answers 5

up vote 4 down vote accepted

"Page Image" is a special kind of SharePoint field defined as Sealed. This means it cannot be removed from the UI once added. However it can be removed programmatically:

SPList list = web.Lists["CustomTest"];
SPField f = list.Fields["Page Image"];
f.Sealed = false;
f.Update();
list.Fields["Page Image"].Delete();

For reference, the field is defined in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\PublishingResources\PublishingColumns.xml.

Attribution credit: my answer on Stack Overflow.

share|improve this answer
add comment

Besides being Sealed, a field can be read-only, hidden and etc. All these factors might prevent the field from deletion. The more suitable method to delete a list field is the following one:

public static bool RemoveField(SPField spField)
{
    if (spField == null)
    {
        WriteErrorToLog("spField is null! Please, provide a valid one");
        return false;
    }

    bool res = false;
    try
    {
        // check if it's a ReadOnly field.
        // if so, reset it
        if (spField.ReadOnlyField)
        {
            spField.ReadOnlyField = false;
            spField.Update();
        }

        // check if it's a Hidden field.
        // if so, reset it
        if (spField.Hidden)
        {
            spField.Hidden = false;
            spField.Update();
        }

        // check if the AllowDeletion property is set to false.
        // if so, reset it to true
        if (spField.AllowDeletion == null || !spField.AllowDeletion.Value)
        {
            spField.AllowDeletion = true;
            spField.Update();
        }

        // If the AllowDeletion property is set,
        // the Sealed property seems not to be examined at all.
        // So the following piece of code is commented.
        /*if(spField.Sealed)
        {
            spField.Sealed = false;
            spField.Update();
        }*/

        // If the AllowDeletion property is set,
        // the FromBaseType property seems not to be examined at all.
        // So the following piece of code is commented.
        /*if(spField.FromBaseType)
        {
            spField.FromBaseType = false;
            spField.Update();
        }*/

        // finally, remove the field
        spField.Delete();
        spField.ParentList.Update();

        res = true;
    }
    catch (Exception ex)
    {
        WriteErrorToLog(ex.Message);
    }

    return res;
}

public static bool RemoveField(SPList spList, string displayNameOrInternalNameOrStaticName)
{
    SPField spField = GetFieldByName(spList, displayNameOrInternalNameOrStaticName);
    if(spField == null)
    {
        WriteErrorToLog(string.Format("Couldn't find field {0}!", displayNameOrInternalNameOrStaticName));
        return false;
    }

    return RemoveField(spField);
}

public static void WriteErrorToLog(string errorMsg)
{
    // write error into log
}

Read my article How to Delete a List Field/Column programmatically, to learn more.

share|improve this answer
add comment

I have seen this before when you add fields that SharePoint consider non-deletable.

You will probably have to delete it programmatically or a tool like SharePointManager

share|improve this answer
add comment

How about hiding the field using manage content types?

List Settings --> Advanced Settings -->Allow Manage content types Click on COntent Type --> click on Page Image field --> Select Hidden?

share|improve this answer
    
Unfortunately, 'Hidden' isn't sufficient for my purposes.. –  Ryan Shripat Oct 14 '09 at 13:26
add comment
  1. First go to Home option in Default Page
  2. Click on list name that you have created.
  3. Click on List setting option in setting tab pane.
  4. Click on Column name in Columns option
  5. Then you get the option to delete. Press it and it will be deleted.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.