Home > SharePoint 2010, SharePoint Problems/Issues > Fixing Unable to locate XML-Definition for CType with SPContentTypeId in SharePoint 2010

Fixing Unable to locate XML-Definition for CType with SPContentTypeId in SharePoint 2010

Damn these orphaned Content Types.  It seems like i’ve been dealing with these more often than anything recently in my SP2010 environment.

This blog relates to the two previous blogs I made regarding Orphaned Content Types:

http://jshidell.com/2013/03/21/remove-orphaned-content-types-in-sharepoint-2010-that-are-associated-with-a-feature/

http://jshidell.com/2012/06/07/removing-a-corrupted-site-column-in-sharepoint-2010/

In this case, orphaned Content Types in my environement would not allow me to activate certain custom features in my environment, or allow me to add specific content types to any doc library.

Viewing the SharePoint 2010 ULS logs I was seeing these errors.

‘Unable to locate the xml-definition for FieldName with FieldId <GUID>’

‘Unable to locate the xml-definition for CType with SPContentTypeId <GUID>’

Both errors are in relation to one another where the FieldName with FieldId are relying on the CType SPContentTypeId.  Since the xml-definition is missing from the CType, SharePoint is unable to locate the definitions to the FieldName with FieldId that is associated with that CType.

How ContentTypes lose there xml-definitions depends on how these Content Types were applied to the environment.  This usually happens when ContentTypes are deployed to the environment by a feature, and then when these features are deactivated and retracted they leave ContentType residue behind, so when trying to reactivate the same feature again, it will throw an error saying that these ContentType already exists.

I’ve seen this happen when ContentTypes are deployed using CAML Query rather than programatically.

To determine which Content Types (CType) are missing xml-definitions you will have to take a look at the Content DB ContentTypes table within SQL.

Below are the steps to resolve this issue.

*NOTE: In some cases, simply retracting and redeploying the solution to the farm, then reactivating the feature can fix this issue.  Try this first, if it does not work follow my steps beblow.

This will require a direct DB modifictions.  Again this is unsupportive by Microsoft, so make sure you open up a case with them to cover you just incase.

Proceed with caution.  I’m not responsible for your farm!

===========================================================================================================

1.  Determine which content database has the orphaned content types.  (Central Administration, Application Management, Site Collection List), Search for the Site Collection that won’t allow you to activate features or add content types, and note down which Content Database it lives in.
2.  Log into your database server (SQL)
3.  Bring up SSMS and bring up a new Query window
4.  Next Type

SELECT * FROM [DATABASENAME].[dbo].[ContentTypes] WHERE ContentTypeId like ‘%<GUID>%’  #This is the GUID for the CType found in the ULS Log.

5.  This will list the Content Type SharePoint its complaining about.  If you examine the results you will notice in the Definition Column there is a NULL value.
6.  Note down the value in the ‘ResourceDir‘ column.  This will tell you the name of the ContentType
7.  Now here is the thing.  HOPEFULLY this content type was deployed successfully at a different scope, so you can copy the content of the xml-definition from a known ‘good’ location.  If you have multiple results for that same GUID determine if all results of that same ContentType have a value in the Definition column.  If one of the results happens to have the value that is not NULL you are in luck.
8.  Inside one of the the results that have a value other than NULL in its Definition, click inside the cell and right click, copy.
9.  Now we are going to update the ContentType that is missing its xml-definition.
10.  Inside the same Query window type and execute query

UPDATE [DATABASENAME].[dbo].[ContentTypes] SET Definition ‘<PASTE CONTENT FROM STEP 8>’ WHERE ResourceDir like ‘<NAME OF CONTENT TYPE>’ and Definition is NULL

11.  After executing script, re-run query from step 4.
12.  Verify now that the ContentType that was missing it’s definition is no longer NULL.
13.  Do the these same steps for all ContentTypes missing their definition.
14.  After all ContentTypes have been updated, go back to your Site Collection to try to activate your feature, or try to add content types to doc libraries.

============================================================================================================

Advertisements
  1. May 23, 2013 at 9:40 pm

    My brother suggested I might like this web site. He was entirely right.
    This post actually made my day. You cann’t imagine just how much time I had spent for this information! Thanks!

  2. Roy Hensens
    November 13, 2015 at 10:44 am

    Just a nice warning here for all who read here: this article suggests executing a direct change query (UPDATE) to a SharePoint content database. Executing this will VOID ALL SUPPORT and WARRANTY from Microsoft and will leave your environment unsupported.

    • November 16, 2015 at 8:14 am

      Do people not read my blog posts? I mentioned this in my blog along with all the others I blogged about regarding DB modifications. Please read

      “This will require a direct DB modifications. Again this is unsupportive by Microsoft, so make sure you open up a case with them to cover you just incase”

  3. January 14, 2016 at 11:08 am

    For those that would like to know. I had to open up another case with Microsoft for a direct DB Mod, and even though it took some time they final approved the case, so this can be done and still have support from Microsoft, as in many of my cases.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: