Search code examples
sharepoint-2010content-type

ContentTypeRef not working as expected, inheriting from System instead of mine


I have a SP project with two features:

  • a first feature that defines some fields, a content type and a list definition
  • a second feature that defines a list instance of the first feature definition

in the second feature, I use the ContentTypeRef element to bind to the content type defined in the first feature. I saw in many blog post and forum thread that Fields are not correctly populated to the list, but it's not my issue (maybe it's related ?)

The instantiated list defines a content type, but instead of inheriting from my content type, it inherits the "System" content type.

Is this behavior correct ? how can I actually inherits my content type instead of system content type ?

thx in advance

[Edit] the simpliest workaround I found is to copy past the content type definition into the contenttypes element of my list schema... but it's still a copy/paste operation (as ugly as it can be)


Solution

  • Please make sure that your content type ID is valid, I never managed to bypass the item content type (0x01) which means that your content type will have an ID of 0x0100{A-GUID}.

    Anyway, even if you defined properly your content type and this one is working as expected when you bind it to a custom list, you'll still need to re-declare it in your list schema with all its field reference and once again, copy most of the definition of your field (I had issue with less than ID, name, display name, type in this area)...

    Eg with the last list I created :

        <ContentTypes>
            <ContentType ID="0x0100FDCCBFFB0FBF4D5C8E069F582412909602" Name="UniverseTranslation" Group="XYZ" Description="Universe Translation" Version="0">
                <FieldRefs>
                    <FieldRef ID="{39BF387B-C20A-4D30-BD17-CB70E4609FA2}" Name="LookupUniverse" DisplayName="Universe" Required="TRUE" />
                    <FieldRef ID="{824F7063-6D09-48CD-B5BA-FE9B5EE36D6A}" Name="WCC_Language" DisplayName="Language" Required="TRUE" />
                    <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Translation" Required="TRUE" />
                    <FieldRef ID="{EC8E4DB7-B715-430B-9B4A-F222F025EFAB}" Name="RichDescription" DisplayName="Description"/>
                </FieldRefs>
            </ContentType>
        </ContentTypes>
        <Fields>
    
            <Field
                ID="{39bf387b-c20a-4d30-bd17-cb70e4609fa2}"
                Name="LookupUniverse"
                DisplayName="Universe"
                Type="Lookup"
                ShowField="Title"
                Required="TRUE"
                EnforceUniqueValues="FALSE"
                List="Lists/Universes">
            </Field>
    
            <Field
                ID="{824F7063-6D09-48CD-B5BA-FE9B5EE36D6A}"
                Name="WCC_Language"
                DisplayName="Language"
                Type="VariationLabelsFieldType"
                Required="TRUE">
            </Field>
    
            <Field
                ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
                Name="Title"
                DisplayName="Translation"
                Type="Text"
                Required="TRUE">
            </Field>
    
            <Field
                ID="{EC8E4DB7-B715-430B-9B4A-F222F025EFAB}"
                Name="RichDescription"
                DisplayName="Rich Description"
                Type="Note"
                NumLines="4"
                RichText="TRUE"
                RichTextMode="Compatible"
                AllowHyperlink="TRUE"
                IsolateStyles="FALSE"
                AppendOnly="FALSE"
                Required="FALSE">
            </Field>
    
        </Fields>
    

    If you can post your content type definition and part of your list schema, I'm pretty sure we'll be able to provide a more relevant help.

    Kindly