Content Type Second Level Inheritance

First off i’d like to note that switching to Inherits=”FALSE” from a Content Type Definition doesn’t mean that the fields from the parent content type aren’t available for the inheriting content type.
This is true for solutions deployed as Farm solutions, Sandboxed solutions have different behaviour.

More info about this :
MSDN

SharePoint 2010 OOB field definitions (Frode’s awesome list)

That said, lets carry on.
Just to be clear, I’ll be handling the farm solution option.

Suppose you have this case, where you’d like to setup multiple content types inheriting from a parent content type.

Each content type should be able to show their own displayname of the inherited fields, let alone that each content type should have their own fields for that matter.

I’ve provided a solution that handles this case, click to download, rename into .ZIP file

Let’s say we have a Child Content Type inheriting from Item (0x01) :

 <?xml version="1.0" encoding="utf-8" ?> 
- <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field Type="User" ID="{DFC4C148-0685-481B-AE94-9F7A0A641DA9}" Name="MerkenTestUserField" DisplayName="Related User" Group="Merken" Title="Leader" Description="Related User Field" Hidden="FALSE" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInFileDlg="TRUE" UserSelectionMode="PeopleOnly" UserSelectionScope="0" Required="TRUE" /> 
  <Field Type="Text" ID="{16484F85-7882-465A-8268-74A6D3B596ED}" Name="MerkenTestMyField" DisplayName="My Text Field" Group="Merken" Title="TextField" Description="My Text Field" Hidden="FALSE" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInFileDlg="TRUE" Required="TRUE" /> 
  <Field Type="Text" ID="{7BDA01FC-4924-4601-8B7A-DF059BF230D4}" Name="MerkenTestMyChildField" DisplayName="My Child Text Field" Group="Merken" Title="TextField" Description="My Child Text Field" Hidden="FALSE" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInFileDlg="TRUE" Required="TRUE" /> 
- <!--  Parent ContentType: Item (0x01) 
  --> 
- <ContentType ID="0x01004af80e3c1b084488bcb80d24aa9b5fcc" Name="Child ContentType From Parent SharePoint Item" Group="Merken" Description="Child ContentType From Parent SharePoint Item" Inherits="FALSE" Version="0">
- <FieldRefs>
  <FieldRef ID="{DFC4C148-0685-481B-AE94-9F7A0A641DA9}" Name="MerkenTestUserField" DisplayName="My UserField in Child" /> 
  <FieldRef ID="{16484F85-7882-465A-8268-74A6D3B596ED}" Name="MerkenTestMyField" DisplayName="My Field in Child" /> 
  <FieldRef ID="{7BDA01FC-4924-4601-8B7A-DF059BF230D4}" Name="MerkenTestMyChildField" /> 
  <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="The Title in Child" Required="TRUE" Sealed="TRUE" /> 
  </FieldRefs>
  </ContentType>
  </Elements>

And the GrandChild Content Type inheriting from Child Content Type :

  <?xml version="1.0" encoding="utf-8" ?> 
- <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field Type="Text" ID="{E12D466A-4490-489B-8825-5A3EFF8C657F}" Name="MerkenGrandChildField" DisplayName="My GrandChild Text Field" Group="Merken" Title="TextField" Description="My GrandChild Text Field" Hidden="FALSE" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInFileDlg="TRUE" Required="TRUE" /> 
- <!--  Parent ContentType: Child ContentType From Parent SharePoint Item (Merken.SharePoint.ContentTypeInheritance\ChildContentType) (0x01004af80e3c1b084488bcb80d24aa9b5fcc) 
  --> 
- <ContentType ID="0x01004af80e3c1b084488bcb80d24aa9b5fcc0038bd791ab5a6406f91b89cae8c958038" Name="GrandChild ContentType From Parent Child ContentType" Group="Merken" Description="GrandChild ContentType From Parent Child ContentType" Inherits="FALSE" Version="0">
- <FieldRefs>
  <FieldRef ID="{E12D466A-4490-489B-8825-5A3EFF8C657F}" Name="MerkenGrandChildField" /> 
  <FieldRef ID="{DFC4C148-0685-481B-AE94-9F7A0A641DA9}" Name="MerkenTestUserField" DisplayName="My UserField in GrandChild" /> 
  <FieldRef ID="{16484F85-7882-465A-8268-74A6D3B596ED}" Name="MerkenTestMyField" DisplayName="My Field in GrandChild" /> 
  <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="The Title in GrandChild" Required="TRUE" Sealed="TRUE" /> 
  </FieldRefs>
  </ContentType>
  </Elements>

If you want to remove fields from the parent, use the

<RemoveFieldRef>

element in the

<FieldRef>

section of the Content Type Definition

Leave a comment