SharePoint Internals – Hristo Pavlov’s Blog

24 June, 2008

Content Type is still in use

Filed under: SharePoint — Tags: , , , , , , — hristopavlov @ 4:01 am

Sometimes you may be getting this error message when you think you shouldn’t be getting it:

Content Type is still in use   at Microsoft.SharePoint.Library.SPRequestInternalClass.SetListContentTypes(String bstrUrl, String bstrListName, String bstrXML, String bstrSqlPrefix, String bstrSqlSuffix)
   at Microsoft.SharePoint.Library.SPRequest.SetListContentTypes(String bstrUrl, String bstrListName, String bstrXML, String bstrSqlPrefix, String bstrSqlSuffix)
 

This could happen either when you are trying to delete the content type via the SharePoint GUI or from your custom code. You may be thinking that this is incorrect, however have you considered this:

1) Actually you may not see documents that are using the content type because you don’t have rights to. SharePoint 2007 has item level security settings. So check all the documents in the list with an account that has full control (e.g. site collection admin).

2) If the list allows both minor and major versions and if any of the documents in the list is a minor version, but also has an existing previous major version (i.e. published version), then SharePoint will refuse to delete the content type if it is used by this last major version, even if the latest minor version is not using it.  I don’t have an explanation about why it is doing it, but this is how it works. It seems that you will need to check in a major version if you want to remove the content type in this case.

3) If the list has the ForceCheckOut flag enabled, then someone may have just added a document and may have not yet pressed “Check In” or may have pressed “Cancel” on the EditForm page. In such a case the document will be added to the list with version 0.1 but will be checked out to that user and will not show up for anyone else (including site collection admins). Actually even if you check through code the SPList.Items with elevated privileges account you will still not be able to see this item if it is not checked out to the elevated account.

One way to detect whether you are having such a “hanging” document is to check the SPList.ItemCount property and see if its value is the same as SPList.Items.Count. If they are different then you may have this type of “hanging” documents in your list. The ItemsCount seems to be stored in an internal array of list properties and counts all the items in the list, while SPList.Items will return only the items you can see.

public int ItemCount

{

    get

    {

        this.EnsurePropsFresh();

        return (int) this.m_arrListProps[20, this.m_iRow];

    }

}

15 Comments »

  1. […] Content Type is still in use […]

    Pingback by Links (6/24/2008) « Steve Pietrek - Everything SharePoint — 25 June, 2008 @ 2:08 am

  2. […] Content Type is still in use […]

    Pingback by Michael Greth MVP SharePoint Blog : SharePoint Kaffeetasse #79 — 26 June, 2008 @ 7:44 am

  3. Great tip – thanks. I was wondering why my ITEMCOUNT – and ITEMS.COUNT were different – and can’t remove Content Type.

    Higher level user (security) and was able to see/remove one of them – but still ONE file ‘hanging’ somewhere/somehow.

    Thanks for your post.

    Comment by Chris OConnor — 10 July, 2008 @ 12:51 am

  4. Thank you for point 2 in your blog. Saved me some hassles. Wish I knew about it in the past.

    Comment by Snackathon — 4 November, 2008 @ 5:38 am

  5. […] – Lastly if you press “Cancel” on the Edit Form after the file has been already uploaded the file and the list item may remain in a strange state where it is only visible to the person who has uploaded the file and is even not visible to the system account. This happens when the document library is in a “Force Check Out” mode. See more in this post. […]

    Pingback by Understanding SharePoint: List Forms « SharePoint Internals - Hristo Pavlov’s Blog — 17 February, 2009 @ 3:11 am

  6. Nice help! THX
    I had the “bug” in a calendar-List, so first i cant find the mistake (no item is listed / checked out)- but with a content-type-view i found the “bastard”-item 🙂

    Comment by Sebastian Hertel — 4 June, 2009 @ 9:37 am

    • #7 is the final step to remove a content type in use. Good find!

      Comment by Jon — 24 February, 2010 @ 5:13 pm

  7. I resolved this issue by logging as system account and taking owner ship of all checked-out pages (from other users too). Then deleting pages created using that particular content type 🙂

    Comment by Satish Kadam — 9 December, 2009 @ 2:19 pm

  8. I just ran into this issue and #2 saved me a lot of time. I had documents that I re-classified from one content type to another but did not publish a major version. Once I did that I could delete the content type from the library and then from the site. I summarized it in the following blog entry: http://sebastianatar.wordpress.com/2010/01/27/content-type-is-still-in-use

    Comment by sebastianatar — 27 January, 2010 @ 2:04 pm

  9. […] class which allows you to track where the content type is being used and there are some good posts about other things to look for when tracking down the offending content type. In SharePoint 2010 […]

    Pingback by The Content Type Is In Use – SharePoint 2010 Error Redux « Nick Hadlee's Blog on SharePoint and Other Occasional Rants… — 24 May, 2010 @ 12:30 am

  10. Very nice article!

    Other issues that can prohibit Content Type deletion are:

    -recycle bin: you might have deleted the offending list, but its still in the Site recycle bin.
    And even if you delete it there, its still in the Site Collection recycle bin under “deleted from end user recycle bin”, so you need to delete it first from one then the other

    -meta data navigation: in sharepoint 2010, if you used a content type in a list and also used its fields (typically taxonomy fields) for meta data navigation, deleting all items, the content type and all traces of the content type isnt enough. Even deleting the meta data filtering items and disabling management of content types couldnt make Sharepoint give up the hooks of the content type. Here i ended up deleting the list to be able to delete it.

    Comment by Anders Rask — 3 August, 2010 @ 2:09 pm

  11. At step (3) above it’s worth adding that Site Collection Admins can also check this through the UI using “Managed checked out files” in the Document Library Settings.

    You then need to “Take Ownership of Selection” before being able to either delete them or change their content type. Painful but it works.

    Comment by PANoone — 12 November, 2010 @ 1:20 am

  12. I was having the same problem with the recycle bin and site collection….I thought but when I checked all of them I did not find any. Then it dawned on me, Version Control….. The content type was being used by the previous version of the item in the library. This is not as easy to fix since we would have to delete that historical version. So, I am trying get agreement to set version history limits….

    Comment by mykeds — 4 January, 2013 @ 5:38 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Create a free website or blog at WordPress.com.