0

I have a site column that was created some time ago, and that column was added to a content type. Then many lists were created using that content type.

Later they decided that field should not exist anymore. The field was removed from the content type manually, but it exists still on the site columns.

When a new list is created based on the content type, the field is added to new lists, even though in old lists its not there.

I know that I shouldnt edit the content type schema, I wonder if I can safely delete the site column manually and thats it?

1

You should remove the column and update your content type as well.

You can do that in two way at least. By a feature activation:

string contentTypeName = "MyCT";
try
{
    var contentType = site.RootWeb.ContentTypes[contentTypeName];
    if (contentType == null)
        return;

    var fields = site.RootWeb.Fields;
    if (fileds.ContainsField("FieldName"))
    {
        var field = fileds.GetField("FieldName");
        if (!contentType.Fields.ContainsField("FieldName"))
        {
            contentType.FieldLinks.Delete("FieldName");
            contentType.Update();
        }
    }
}}

another way is by powershell:

$web = Get-SPWeb http://portal
$ct = $web.ContentTypes["MyCT"]
$spFieldLink = New-Object Microsoft.SharePoint.SPFieldLink ($web.Fields["FieldName"])
$ct.FieldLinks.Delete($spFieldLink.Id)
$ct.Update()
$web.Dispose()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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