Archive for March, 2013

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

March 22, 2013 4 comments

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:

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.


Remove Orphaned Content Types in SharePoint 2010 That Are Associated With a Feature.

March 21, 2013 4 comments

This blog relates to an earlier blog I have where there were orphaned content types found in content databases that needed to be removed because it prevented me from activating Site Collection features.

For this blog I will discuss how you can remove Orphaned Content Types found in your Site Collection Site Content Type lists that you can not delete through the SharePoint GUI because they are associated with a feature that is no longer deployed or unavailable in your SharePoint 2010 farm, and you no longer need these Content Types.

In my case I had 8 different Orphaned Content Types that were left behind after a solution was retracted from my SharePoint 2010 farm.  Depending on how these solutions were developed in most cases once a solution is retracted it should also take along with it their content types.  However this was not the case for me.

The solution I was dealing with here was Visual Fusion, this 3rd party solution was no longer needed in our environment and I needed to get rid of all its references.

Since Visual Fusion does not automatically remove their content types after retracting, these content types still lived in our content databases.

When I tried to delete these content types from the Site Content Type lists I got an error stating that this content type is part of a feature, and would not allow me to delete it.

What happens here is there is a column(field) in each ContentTypes table in each Content Database called isFromFeature  This column specifies if each content type is associated to a feature or not.  If the flag=1 its associated to a feature if the flag=0 then it is not.

The only way around fixing this problem is to do a direct DB modification.

As I stressed in my blog link above doing any type of DB modificiation/fix is not supported by Microsoft unless you get direct approval from them that its ok.  For all my cases like this I open up a case with them to protect me just incase I need premier Microsost support later.

So if you ever run into this issue, make sure you get Microsoft’s approval before proceeding, unless you don’t care about receiving premier support.

Below are the steps to fix this issue:  Proceed with caution.  I’m not responsible for your farm.


1.  Determine which Content Database(s) have these orphan content types.  If you have multiple content databases, you can determine which site collection lives in which Content Database by going to (Central Administration, Application Management, View all site collections)

2.  After you determine which Content Database(s) need these orphaned content types removed, head over to your Database Server (I’m assuming SQL).

3.  Once on your database server bring up SSMS and open up a new query window.

4.  Type inside the query window, and execute query

SELECT * FROM [NAME OF CONTENT DATABASE].[dbo].[ContentTypes] WHERE Definition like ‘%NAME OF Content Type%’

5.  If you look at the results you should see the IsFromFeature flag set to 1 for these content types

6.  We will now want to update this flag from 1 to 0

7.  Inside that same query window, type

UPDATE [NAME OF CONTENT DATABASE].[dbo].[ContentTypes] SET IsFromFeature = 0 WHERE Definition like ‘%NAME OF Content Type%’

8.  This will update the flag in IsfromFeature from 1 to 0

9.  Run the Query command from step 4 again to verify that the flag did change.

10.  If successful, go back to your Site Collection Site Content Types, and now you should be able to open up each Content Type and delete.


Hopefully this is hopeful for others who have encountered this same problem