Problem
Unable to make changes to the title field when declaring a content type in SharePoint 2010. For example, the following declaration has NO EFFECT on the title field being required-

Workaround

Attach a feature receiver to your content type and use the object model to modify the Title field-

Discussion

This is a ‘cheap’ solution so to speak because modifying the content type via the object model disconnects it from the XML definition thus making future updates messier (Read More).

I’m a strong advocate of doing things declaratively and this solution clearly violates that rule. A colleague of mine made a case for writing content types completely non-declaratively using the object model.

What best practices do you follow when writing content types?

Tagged with:
 

3 Responses to Cannot modify Title field in Content Type declaration

  1. Pjotr says:

    Hi, it is possible to hide the default title field without code . But all the examples found on the internet are incomplete.

    The ContentType attribute Inherits should be FALSE. Then you can add a FieldRef ID={default title id} and set hidden to true and the ShowIn..Form attributes to False

    Below a complete example:

    <elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <field Type="Choice" DisplayName="Retention period" Description="What is the retention period" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="Dropdown" FillInChoice="FALSE" Group="Custom columns" ID="{8D2407BB-75DA-46A5-80CC-70C1B271D49D}" SourceID="{b30feb85-7edc-4041-9708-9fc8386a8491}" StaticName="RetentionPeriod" Name="RetentionPeriod">
    <default>5 year</default>
    <choices>
    <choice>1 year</choice>
    <choice>5 years</choice>
    <choice>10 years</choice>
    <choice>20 years</choice>
    <choice>Permanent</choice>
    </choices>
    </field>
    <contenttype ID="0x0101002EAA7A058444094AA16DDF6ECECBF774" Name="Archivedocument" Description="Create a new archive document." Group="Custom content types" Inherits="false" Hidden="false" ReadOnly="false" Sealed="false">
    <fieldrefs>
    <fieldref ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Hidden="TRUE" Required="FALSE" ShowInDisplayForm="FALSE" ShowInNewForm="FALSE" ShowInEditForm="FALSE" />
    <fieldref ID="{8D2407BB-75DA-46A5-80CC-70C1B271D49D}" Name="RetentionPeriod" DisplayName="Retention period" />
    </fieldrefs>
    </contenttype>

  2. Ah! Thanks for the tip Pjotr

  3. Gog says:

    Thank you so much Pjotr. I lost more than two hours tweaking schema. Changing Inherits to FALSE did the trick.

    Thanks!

Leave a Reply

Your email address will not be published.

Set your Twitter account name in your settings to use the TwitterBar Section.