0

I just created a couple of site columns and content types that reference them through VS2010. I updated one of the fields and then tried to redeploy, but after retracting, deploy failed because the site columns previously created were still there. I tried to delete them manually from the UI, and got an alert box with this message:

Site columns which are included in content types cannot be deleted. Remove all references to this site column prior to deleting it.

I dug around in SharePoint Manager and didn't find any references, so I used powershell to enumerate all the content types and lists looking for references to my site columns and found nothing.

I tried to delete using PowerShell like this:

$web.Fields.Delete("StartTime")

which resulted in this error:

Exception calling "Delete" with "1" argument(s): "Site columns which are included in content types or on lists cannot be deleted. Please remove all instances of this site column prior to deleting it." At line:1 char:19 + $web.Fields.Delete <<<< ("StartTime") + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException

Finally, a simple inspection of the columns in PowerShell shows the following:

Title Id CanBeDeleted ParentList Sealed ListsFieldUsedIn
----- -- ------------ ---------- ------ ----------------
Start Time OBE 6fa0d85b-9af1-408b-835f-d4c66536... True False {}
Time Tracker Tags 92bc866b-0415-45f0-b431-d4df69c4... True False {}

I'm experienced with MOSS 2007 and new to SP2010, but I've never seen this happen before. Anyone have any hints?

1

So you did deployed your column via a Feature right? This also means that you won't be able to remove it manually.

You need to make sure you emptied the Recycle Bin (both sub-sites and site collection) to attempt removing used references. Than try to remove again your feature.

ON YOUR OWN RISK (i did successfully fixed some CTs this way...but you never know):

use this to locate information about your column http://blog.sharepointsite.co.uk/2011/05/corrupt-site-column-cannot-be-deleted.html

and then use this http://blog.tylerholmes.com/2008/02/deleting-content-types-in-sharepoint.html to actually delete the offending CT with its columns.

1

If you go to "Site Actions > Manage content and structure" and find the offending item - there's a button to show item dependencies. This way you can weed out what is still using the field and remove it before removing the field altogether.

1

This is (a backup copy of) the article by Tyler Holmes which is mentioned by Marius Constantinescu. I have used it a couple of times and I would hate to see it disapear...

DELETING CONTENT TYPES IN SHAREPOINT 2007: A TROUBLESHOOT [Updated Nov, 13 2008]

Whenever it comes time to delete a content type, it's either a 10 second job or a multi hour why-did-I-become-a-developer endeavor. Either the content type is completely orphaned (it's not being used at all) and easy to delete, or it's used in a tonne of places, most of which will be difficult to find and the treasure hunt is on! It's of note that before a content type can be delete there can be no items in any lists that use it and it can not exist in any lists.

This blog post will cover how to delete a content type and how to troubleshoot the most common error, The content type is in use.

Deleting a Content Type For the record, the series of steps to delete a content type are as follows:

  1. Site Actions->Site Settings.
  2. Under Galleries click Site content types.
  3. Find the content type you wish to delete and click on it.
  4. Click the Delete this site content type link. At this point the content type will either be deleted, or you'll get an error message saying something like:

The content type is in use.

If you have errors turned on in the web.config (setting customErrors="Off" and CallStack="true") your error message may look a lot more like:

The content type is in use. at Microsoft.SharePoint.SPContentTypeCollection.DeleteFromWeb(SPContentTypeId id, String strName) at Microsoft.SharePoint.SPContentTypeCollection.Delete(SPContentType Id id) at Microsoft.SharePoint.SPContentType.Delete() at Microsoft.SharePoint.ApplicationPages.ManageContentTypePage.DeleteContent Type() at Microsoft.SharePoint.ApplicationPages.ManageContentTypePage.System.Web. UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

If you get one of the messages above then you need to get a little more creative. Your options are either digging through all the lists in the site collection and trying to figure out who's using the content type, OR running a stored procedure to determine the lists that are using the content type. I don't know about you but the latter sounds a little more time efficient.

Finding Lists/Libraries using the Content Type The first thing we'll need is access to the content database with a SQL Client like SQL Management Studio. There's a tutorial on how to connect here.

We'll also need a tool like the SharePoint Explorer for WSS 3.0 (needs to be run on the WSS server itself) to figure out what the SiteCollection ID is.

Ok, lets get to it.

Determining the Site Collection ID of your Site Collection

  1. Run the SharePoint Explorer (SPE) on the server that's hosting the WSS site.
  2. Find your Web Application with SPE and click on the Content Databases tab to figure out what the name of the SQL Server instance hosting the content and what the name of the content database is.

Sharepoint Content Database Name and SQL Instance Name

  1. Click on the Site Collection itself and grab the ID property of the site, we'll need this when we run the stored procedure.

Identifying the Site Colleciton Id with Sharepoint Explorer

  1. The last thing we'll need is the ContentTypeID of the content type we want to delete, the easiest way to get this is right out of the URL when you go to delete (or edit) the content type (Site Settings->Site Content Types->Click on your content type). Here's a sample URL. http://w2k3-tyler-virt/_layouts/ManageContentType.aspx? ctype=0x010700037B79D2DD41C24A8F55D82FC6B71FAC&Source=http%3A%2F% 2Fw2k3%2Dtyler%2Dvirt%2F%5Flayouts%2Fmngctype%2Easpx In this example the Content Type ID is 0x010700037B79D2DD41C24A8F55D82FC6B71FAC.
  2. Now we open up the SQL Server Management Studio, connect to the [ServerName]\OfficeServers instance and run the following stored procedure against our sites content database (we figured this out in #2). [proc_ListContentTypeInUse] [SiteCollectionId], [ContentTypeId] Or in out case: [proc_ListContentTypeInUse] 'D2F8C831-4CA7-41C0-8497-82F897B61B2B', 0x010700037B79D2DD41C24A8F55D82FC6B71FAC What you get back is a result set showing all the lists that the given ContentType is being used in.
    Result set from proc_ListContentTypeInUse, finding all the lists in the site collection that use a given Content Type

If you go and remove the content type from all those lists you should be good to go and that pesky error message will go away.

[Updated Nov, 13 2008] You can also run the following query which will give you the SiteId, WebId, ListId of where the content type is in use!

SELECT SiteId, sys.fn_varbintohexstr(ContentTypeId) AS ID, WebId, ListId, IsFieldId, Class FROM ContentTypeUsage WHERE (sys.fn_varbintohexstr(ContentTypeId) LIKE '[ContentTypeID]%') Hope that saves someone somewhere some time.

My Very Best, Tyler

0

Isn't "StartTime" an built-in column used by the Tasks content types?

1
  • there is an OOTB column called "Start Date". – Ben Collins Feb 21 '11 at 16:25

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.