Custom Content Types and Inherits in SharePoint 2010

SharePoint 2010 adds an attribute named Inherits which you can use when defining custom content types in CAML. When you create a content type in Visual Studio 2010, this attribute is included and it’s set to TRUE. The description of the Inherits attribute in the SDK reads:
Optional Boolean. The value of this attribute determines whether the content type inherits fields from its parent content type when it is created.
If Inherits is TRUE, the child content type inherits all fields that are in the parent, including fields that users have added.
If Inherits is FALSE or absent and the parent content type is a built-in type, the child content type inherits only the fields that were in the parent content type when SharePoint Foundation was installed. The child content type does not have any fields that users have added to the parent content type.
If Inherits is FALSE or absent and the parent content type was provisioned by a sandboxed solution, the child does not inherit any fields from the parent.
So it would seem that this attribute controls which fields a content type will inherit from its parent. That it does, although likely not in the way that you would expect. It also has other effects that are not immediately obvious. Let’s take a look at the following example in some different scenarios:
 
<ContentType ID="0x0104007570511f066f4032b78e1041afc72fb7"
     Name="SharePointProject5 - ContentType1"
     Group="Custom Content Types"
     Description="My Content Type"
     Inherits="?????"
     Version="0">
  <FieldRefs>
 <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Announcement" Required="TRUE" />
 <FieldRef ID="{d2311440-1ed6-46ea-b46d-daa643dc3886}" Name="PercentComplete" />
  </FieldRefs>
</ContentType>
Here, we are creating a custom content type that inherits from Announcement. It changes the display name of the Title field to Announcement and adds a field for percent complete (I know, a little contrived, but it is just an example). Now lets look at the scenarios:
Farm Solution with Inherits set to False 
This works as described above. The behavior in this case, at least as far as I can tell, is the same as it was in SharePoint 2007.
ContentType01
Sandboxed Solution with Inherits set to False
In this case, although the parent content type is recognized as Announcement, none of the fields come over unless they are specifically included as a FieldRef in the child type.
ContentType03
Farm or Sandboxed Solution with Inherits set to True
In these cases the percent complete field is added but the changes to the properties of the Title field are ignored. In fact, changes to any of the properties of fields inherited from the base type will be ignored. Also, any attempts to remove fields inherited from the base type will be ignored. As far as I can tell, the only thing you can do when Inherits is true is add additional fields to the type – everything else is ignored.
ContentType02
One final note. The concept of Inherits and the behaviors described above only apply when creating content types using CAML. Creating content types with code, whether it’s a full trust or sandboxed solution, works the same as it did in SharePoint 2007.

Comments