locked
How to delete a content type created by a feature RRS feed

  • Question

  • Hi,

    I have a content type which was created with a feature and now I need to remove it from the Site Content Types. I've deactivated and uninstalled the feature and when I try to delete the content type I receive the following message:

    The content type "Arquivo" is part of an application feature.   at Microsoft.SharePoint.SPContentTypeCollection.DeleteFromWeb(SPContentTypeId id, String strName)
       at Microsoft.SharePoint.SPContentTypeCollection.Delete(SPContentTypeId id)
       at Microsoft.SharePoint.SPContentType.Delete()
       at Microsoft.SharePoint.ApplicationPages.ManageContentTypePage.DeleteContentType()
       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)

    How can I delete it?

    Thanks in advance.

    Claudia

    Friday, January 23, 2009 8:35 PM

Answers

  • Hello

    The trick proposed in this post did not help me I suggest using the code proposed in the link below to discover the usage of the contentType hence you can delete all its refrences, so that you can delete it itself http://msdn.microsoft.com/en-us/library/ms453791.aspx

    Mohamed Hachem ;)


    Momo
    • Proposed as answer by Tofig Thursday, January 13, 2011 9:54 AM
    • Marked as answer by Mike Walsh FIN Thursday, January 13, 2011 12:45 PM
    Thursday, August 19, 2010 8:54 PM
  • Hi Claudia,

    Here is the solution for deleting a custom Content type.

    1. Go Site Actions> Modify All Site Settings:

    2. Go to "Site Content Type"

    3. in the Site Content Type Gallery click on the Custom content type which you have created under "Custom Cntent Type"

    4.Now Go to "Advanced Settings" under  "Settings"

    5.  Under "Update all content types inheriting from this type" Click "NO" then click "OK"

    6. Now Under "Settings" Click "Delete This Site Content Type"

    7. Your job will be done.

    Hope This helps :)

    Thanks
    Amreesh




    Monday, March 2, 2009 7:52 AM

All replies

  • are there any items that are still using the content type?
    Tony Testa www.tonytestasworld.com
    Sunday, January 25, 2009 2:42 AM
  • Before you deactivate the feature you need to make sure that no items or lists are using the feature.  Also make sure you that are not using the contenttypebinding element in your feature as that will also prevent you from deleting the content type.
    Sunday, January 25, 2009 11:09 PM
  • Tony and Gary,

    I've checked the content type and it's not being used. I looped through all the site collection and its subsites recursively to show me all the content types associated with all the lists and the content type is not being used at all.

    What could be preventing it from being deleted?

    Thanks,

    Claudia

     

    Monday, January 26, 2009 12:34 PM
  • Sorry to continue the questioning! (but...) Are you sure that there are no list content types that inherit from your original site content type? These can be created when deploying Content Types via a Feature. Could it be that because a List Content Type is inheriting from your site content type that would stop said Site Content Type from being deleted?

    See this article for an overview;

    http://blog.sharepoint.ch/2008_06_01_archive.html


    Blog; http://www.the-north.com/sharepoint --- Posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, January 26, 2009 12:59 PM
  • Hi, Jamie, I'm sure there's no other content type inheriting from the one I want to delete... And this one is not associated with any lists since I removed all associations before trying to delete it.

    Thanks,

    Claudia

    Monday, January 26, 2009 3:00 PM
  • Claudia,

    Have a look at this guidance by Vince Rothwell. He details a nice way to check the database for references to the content type to be absolutely sure.

    http://blog.thekid.me.uk/archive/2008/11/03/a-tip-when-looking-at-the-sharepoint-content-db.aspx

    J


    Blog; http://www.the-north.com/sharepoint --- Posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, January 30, 2009 11:15 AM
  • I'm having this same issue.
    There are definitely no lists using the content type and no other content types deriving from it.
    I've tested this by creating a brand new web application / site collection / etc, deploying my feature, and then immediately retracting it.
    It leaves behind my content type and when I try to delete it manually I get 'The content type "Custom Type" is part of an application feature.'
    I'm not sure why it's being left behind or why it's now impossible to delete.
    Any help would be awesome.

    Thanks,
    Joe
    Thursday, February 12, 2009 9:51 PM
  • Hi Claudia,

    Here is the solution for deleting a custom Content type.

    1. Go Site Actions> Modify All Site Settings:

    2. Go to "Site Content Type"

    3. in the Site Content Type Gallery click on the Custom content type which you have created under "Custom Cntent Type"

    4.Now Go to "Advanced Settings" under  "Settings"

    5.  Under "Update all content types inheriting from this type" Click "NO" then click "OK"

    6. Now Under "Settings" Click "Delete This Site Content Type"

    7. Your job will be done.

    Hope This helps :)

    Thanks
    Amreesh




    Monday, March 2, 2009 7:52 AM
  •  I had the same problem.  Here's the sequence of events that caused the problem and what I did that seemed to fix it.

    1) Installed Feature
    2) Used Content Types from Feature in several lists
    3) Removed Content Types from Lists
    4) Deactivated Feature
    5) Uninstalled Feature
    6) Replaced Feature GUID and Re-Installed
    7) Attempted to activate and recieved "content type is part of an application feature" message
    8) Uninstalled Feature again
    9) Navigated to each list and removed every column that was being used by the former content types (Note these were not deleted when I removed the content types from the lists)
    10) Checked Site Content Types and Site Columns to make sure no entries remained
    11) Successfully Re-installed/Activated Feature

    I guess the columns were holding a reference back to the original Content type and Feature.

    Hope this helps someone else,

    Mel
    Monday, March 9, 2009 7:28 AM
  • This doesn't work for me so not sure why it's marked as an answer.
    Thursday, November 26, 2009 10:35 AM
  • Definitely not an answer as it doesn't work.
    Thursday, November 26, 2009 10:59 AM
  • I cannot set my feature to not inherit, it keeps reverting back to "Yes", this is definitely an answer. 
    Monday, March 8, 2010 8:19 PM
  • This site seems to have a lot of wrong posts marked as "Answers", even when they are not answers at all -- they are often just copy & pastes from documentation, suggesting the poster didn't even really read the thread. Is the "Report as Abuse" button appropriate for them? I don't know.
    Tuesday, April 20, 2010 2:59 PM
  • Hello

    The trick proposed in this post did not help me I suggest using the code proposed in the link below to discover the usage of the contentType hence you can delete all its refrences, so that you can delete it itself http://msdn.microsoft.com/en-us/library/ms453791.aspx

    Mohamed Hachem ;)


    Momo
    • Proposed as answer by Tofig Thursday, January 13, 2011 9:54 AM
    • Marked as answer by Mike Walsh FIN Thursday, January 13, 2011 12:45 PM
    Thursday, August 19, 2010 8:54 PM
  • here is a very good explanaition about content types, references and features:

    http://www.collaboris.co.uk/blogs/09-05-16/Upgrading_SharePoint_Content_Types.aspx

    it also present a workarond to delete a content type:

    Test Steps:

    1.       Deploy a Content Type  (via Feature and CAML)

    2.       Reference it in a list

    3.       Change the “name” of the Content Type  in the GUI

    4.       Delete the Reference From the List

    5.       Deactivate and Uninstall the Feature

    Outcome:

    1.       Feature is deactivated

    2.       Content Type is removed

     

     

    Thursday, January 13, 2011 10:10 AM
  • As for updating the content types, the definition in the feature is just an instruction to SharePoint to create the contnet type when the feature is activated, but reactivating (using the -force argument) does not push the changes. So geting changes pushed down can be done using code by looping through sites and lists calling the .update(true) method. Sample code looks like this:

    SPField field = spWeb.Fields[“YourNewField”]; //pick one from the site column collection or create a new one.
    SPFieldLink fieldLink = new SPFieldLink(field);
    SPContentType contentType = spWeb.ContentTypes[“Site Level Content Type”];
    contentType.FieldLinks.Add(fieldLink);
    contentType.Update(true);

     

    Thursday, January 13, 2011 11:11 AM
  • Søren Nielsen has wrote a very nice extension to stsadm, that enables propogating the content type changes

    http://soerennielsen.wordpress.com/2007/09/11/propagate-site-content-types-to-list-content-types/

    it is more or less and alternative for deleting content types console application from Ms http://msdn.microsoft.com/en-us/library/ms453791.aspx

     

    Thursday, January 13, 2011 11:32 AM