SharePoint 2010, RemoveFieldRef and Inherits=”true”

I am brand new to the Visual Studio 2010 templates for SharePoint, having relied on the WSPBuilder toolkit in the past for all my previous SharePoint work. I created what I thought would be a simple ContentType definition inheriting from Item (0x01) using Visual Studio and this is what I got:

   1: <?xml version="1.0" encoding="utf-8"?>
   2: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   3:   <!-- Parent ContentType: Item (0x01) -->
   4:   <ContentType ID="0x01005ac69ad99b164765a7fcb7610c5bfa92"
   5:                Name="SolutionPackage - ContentType1"
   6:                Group="Custom Content Types"
   7:                Description="My Content Type"
   8:                Inherits="TRUE"
   9:                Version="0">
  10:     <FieldRefs>
  11:     </FieldRefs>
  12:   </ContentType>
  13: </Elements>

I added two new fields to the FieldRefs element as well as one RemoveFieldRef to remove the title column as it did not really fit my scenario. I published to my SharePoint 2010 development environment and was bothered that my Title column was not removed. Here was what I published that did not immediately work:

   1: <?xml version="1.0" encoding="utf-8"?>
   2: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   3:   <!-- Parent ContentType: Item (0x01) -->
   4:   <ContentType ID="0x01005ac69ad99b164765a7fcb7610c5bfa92"
   5:                Name="SolutionPackage - ContentType1"
   6:                Group="Custom Content Types"
   7:                Description="My Content Type"
   8:                Inherits="TRUE"
   9:                Version="0">
  10:     <FieldRefs>
  11:       <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title"/>
  12:       <FieldRef ID="{4c56a001-732d-4605-b7ac-1106de977439}" Name="PlantNames" DisplayName="Plant Names" />
  13:       <FieldRef ID="{e0e4af84-4013-4f43-a21b-b3862da37ce1}" Name="OperationsSection" DisplayName="Operations Section"/>
  14:     </FieldRefs>
  15:   </ContentType>
  16: </Elements>

 

After spending more time that I would expect to remove the title field, something which I had done many many times, I looked up on MSDN for the ContentType definition to see what I was missing:

http://msdn.microsoft.com/en-us/library/aa544268.aspx

What stand out now, is the Inherits="TRUE" section that is new to SharePoint 2010 foundation. If you look at the previous version on the ContentType definition for Windows SharePoint Services 3, you will that Inherits is not there:

http://msdn.microsoft.com/en-us/library/aa544268(v=office.12).aspx.

Inherits is defined as:

Inherits
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, to remove the Title field using the RemoveFieldRef element, you must also remove the Inherits attribute entirely (or set Inherits=”False”) in the content type definition:

   1: <?xml version="1.0" encoding="utf-8"?>
   2: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   3:   <!-- Parent ContentType: Item (0x01) -->
   4:   <ContentType ID="0x01005ac69ad99b164765a7fcb7610c5bfa92"
   5:                Name="SolutionPackage - ContentType1"
   6:                Group="Custom Content Types"
   7:                Description="My Content Type"
   8:                Inherits="False"
   9:                Version="0">
  10:     <FieldRefs>
  11:       <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title"/>
  12:       <FieldRef ID="{4c56a001-732d-4605-b7ac-1106de977439}" Name="PlantNames" DisplayName="Plant Names" />
  13:       <FieldRef ID="{e0e4af84-4013-4f43-a21b-b3862da37ce1}" Name="OperationsSection" DisplayName="Operations Section"/>
  14:     </FieldRefs>
  15:   </ContentType>
  16: </Elements>

(Always read MSDN when in doubt!)