Thursday, February 12, 2009

Deleting content Types in Sharepoint 2007 (The content type is in use)

Sometimes when you try to delete content type you faced error: The content type is in use.

Finding Lists/Libraries using the Content Type:
  1. We 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.
  2. We need 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
  3. Now connect content database
    run stored procedure
    [proc_ListContentTypeInUse] [SiteCollectionId], [ContentTypeId]Or in out case:
    [proc_ListContentTypeInUse] 'D2F8C831-4CA7-41C0-8497-82F897B61B2B', 0x010700037B79D2DD41C24A8F55D82FC6B71FAC

or run query:
SELECT SiteId, sys.fn_varbintohexstr(ContentTypeId) AS ID, WebId, ListId, IsFieldId, Class
FROM ContentTypeUsageWHERE (sys.fn_varbintohexstr(ContentTypeId) LIKE '[ContentTypeID]%')

Remove these records and error appears when you try to delete will disappear.

1 comment:

Steve P said...

Tarek,

We have been working on a tool to graphicaly visualize and maintain SharePoint metadata including content types, columns and list. The product is currently in open beta. You can learn more and download from our site http://www.metavistech.com