0

I have a custom content type with a custom list with said content type as primary.

Requirements dictates that the Title field should be replaced by another field - thus the content type does not inherit from its parent, i.e. does not have the Inherit attribute.

<ContentType ID="0x01000e40dca5144b49e6a969a143f4bcfb12"
              Name="Due date"
              Group="$Resources:MagicalProject,MagicalContentType_GroupName;"
              Description=""
              Version="0">
  <FieldRefs>
    <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title"/>
    <FieldRef ID="{542A76A6-C6BD-4AF4-BE26-FA5690450E03}" Name="NumberOfWorkDays" Required="TRUE"/> <!-- This is the replacement for "Title" -->
    <FieldRef ID="{6D819DF3-A783-4026-B6E2-E6EAC6CA3B00}" Name="FormStepTaxHTField0"/>
    <FieldRef ID="{6D819DF3-A783-4026-B6E2-E6EAC6CA3B01}" Name="ManagedMetadataFormStep" Required="TRUE"/>
  </FieldRefs>
</ContentType>

In my list definition I set the above content type as the only content type associated with the list;

<ContentTypes>
  <ContentTypeRef ID="0x01000e40dca5144b49e6a969a143f4bcfb12" />
</ContentTypes>

The deployment goes well as expected. The content type is successfully created and has the correct fieldrefs:

enter image description here

But when I then go to the list that is created with this content type, the view consists of nothing (i.e. no columns what so ever are displayed) and when I check the list settings I can see that the Due Date content type is indeed the primary one, but none of the fields are on the list. When I check the content type I can see it has itself as its parent with no columns:

enter image description here

As soon as I add the Inherit="TRUE" attribute it works, but has the Title field. I have multiple custom content types which are supposed to not have the Title field and they all have the same symptoms, so it's not a stand-alone issue.

Is this a bug from Microsoft's side or am I just missing something?

0

After hours of immense googling, blog reading, and interpretation I managed to find a solution to my problem.

According to MSDN (and many others):

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.

The highlighted text above caught my eye and got me thinking that this might also affect list definitions which gets the content type associated in the Schema.xml file.

So the solution was to do the following:

  1. Paste the ContentType CAML into the <ContentTypes> tag in the list definitions Schema.xml
  2. Paste all the Field CAML for the fields in the content type's <FieldRefs> into the Fields tag in the list definition.

So I ended up with the following result in my list definition's Schema.xml:
Keep in mind that this is only necessary for content types with Inherits="FALSE" or absence of the Inherits attribute.

<List xmlns:ows="Microsoft SharePoint" Title="Due date list" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/MyMagicalProject-DueDateListDefinition" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>
      <ContentType ID="0x01000e40dca5144b49e6a969a143f4bcfb12" Name="Due date" Group="$Resources:MagicalProject,MagicalContentType_GroupName;" Description="" Version="0">
        <FieldRefs>
          <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" />
          <FieldRef ID="{542A76A6-C6BD-4AF4-BE26-FA5690450E03}" Name="NumberOfWorkDays" Required="TRUE" />
          <FieldRef ID="{6D819DF3-A783-4026-B6E2-E6EAC6CA3B00}" Name="FormStepTaxHTField0" />
          <FieldRef ID="{6D819DF3-A783-4026-B6E2-E6EAC6CA3B01}" Name="ManagedMetadataFormStep" Required="TRUE" />
        </FieldRefs>
      </ContentType>
    </ContentTypes>
    <Fields>
      <Field Group="$Resources:MagicalProject,MagicalSiteColumn_GroupName;" ID="{542a76a6-c6bd-4af4-be26-fa5690450e03}" Name="NumberOfWorkDays" DisplayName="Number of work days" Type="Text" LinkToItem="TRUE" ListItemMenu="TRUE" />
      <Field Group="$Resources:MagicalProject,MagicalSiteColumn_GroupName;" ID="{6d819df3-a783-4026-b6e2-e6eac6ca3b00}" Name="FormStepTaxHTField0" DisplayName="FormStepTaxHTField0" Type="Note" ShowInViewForms="FALSE" Hidden="TRUE" />
      <Field Group="$Resources:MagicalProject,MagicalSiteColumn_GroupName;" ID="{6d819df3-a783-4026-b6e2-e6eac6ca3b01}" Name="ManagedMetadataFormStep" DisplayName="Step" Type="TaxonomyFieldType" ShowField="Term1033" Required="TRUE" EnforceUniqueValues="FALSE">
        <Customization>
          <ArrayOfProperty>
            <Property>
              <Name>TextField</Name>
              <Value xmlns:q6="http://www.w3.org/2001/XMLSchema" p4:type="q6:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">
                6D819DF3-A783-4026-B6E2-E6EAC6CA3B00
              </Value>
            </Property>
          </ArrayOfProperty>
        </Customization>
      </Field>
    </Fields>

    ...

  </MetaData>
</List>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy