This week I’m writing some labs for the Advanced SharePoint Delopment course we are organizing here at U2U. Seen the things Patrick want to achieve in this course, it is going to be a challenging week! One of the first challenges is developing a content type feature for a Student:
<FieldRefs>
<FieldRef ID="{6B7EB650-9ABB-4f6d-959A-BC30EF507067}"
Name="StudentID"/>
<FieldRef ID="{3EB9CAF3-C9D6-4857-A297-7D2983A0B5C5}"
Name="FName"/>
<FieldRef ID="{44D3AA0F-B35F-4c7d-94F4-88824823D284}"
Name="LastName"/>
<FieldRef ID="{038D1503-4629-40f6-ADAF-B47D1AB2D4FE}"
Name="Company"/>
<FieldRef ID="{963AE87B-4FE3-467f-91C3-7C878CC4BFF7}"
Name="Email"/>
<FieldRef ID="{fc2e188e-ba91-48c9-9dd3-16431afddd50}"
Name="WorkAddress"/>
<FieldRef ID="{0E6A0F76-DD45-4ea9-926D-D0A90CED5BA4}"
Name="PostalCode"/>
<FieldRef ID="{6ca7bd7f-b490-402e-af1b-2813cf087b1e}"
Name="WorkCity"/>
<FieldRef ID="{8CD101C6-0667-48cf-97E4-B0DE9E7873E5}"
Name="Country"/>
<FieldRef ID="{32045CEE-D805-4031-A9E2-87A227CABD7E}"
Name="Telephone"/>
<FieldRef ID="{F6CC5286-FF3F-412e-BA42-0691A560EC67}"
Name="Remarks"/>
</FieldRefs>
After deploying my site columns feature and content type feature, I created a content type enabled list based on my own content type. I also removed the base content type, which is Item.
When I wanted to add an item to my Students list I saw that the Title field was still there, even if I hadn’t defined it in my content type.
The explanation for this is that I derived my content type from the Item content type, which has the Title field included. When I was making my list depending on my content type I could already have seen it in the Settings page:
Clearly, after removing the Item content type, the Title is still there because it is also part of the Students content type.
If you don’t want certain fields of your base content type (in my case it is Title) to appear in your own content type, you need to add an extra element to your content type definition, namely the <RemoveFieldRef> element.
My content type now looks like this:
<FieldRefs>
<RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
Name ="Title"/>
<FieldRef ID="{6B7EB650-9ABB-4f6d-959A-BC30EF507067}"
Name="StudentID"/>
<FieldRef ID="{3EB9CAF3-C9D6-4857-A297-7D2983A0B5C5}"
Name="FName"/>
<FieldRef ID="{44D3AA0F-B35F-4c7d-94F4-88824823D284}"
Name="LastName"/>
<FieldRef ID="{038D1503-4629-40f6-ADAF-B47D1AB2D4FE}"
Name="Company"/>
<FieldRef ID="{963AE87B-4FE3-467f-91C3-7C878CC4BFF7}"
Name="Email"/>
<FieldRef ID="{fc2e188e-ba91-48c9-9dd3-16431afddd50}"
Name="WorkAddress"/>
<FieldRef ID="{0E6A0F76-DD45-4ea9-926D-D0A90CED5BA4}"
Name="PostalCode"/>
<FieldRef ID="{6ca7bd7f-b490-402e-af1b-2813cf087b1e}"
Name="WorkCity"/>
<FieldRef ID="{8CD101C6-0667-48cf-97E4-B0DE9E7873E5}"
Name="Country"/>
<FieldRef ID="{32045CEE-D805-4031-A9E2-87A227CABD7E}"
Name="Telephone"/>
<FieldRef ID="{F6CC5286-FF3F-412e-BA42-0691A560EC67}"
Name="Remarks"/>
</FieldRefs>
Clearly, when now making my list depending on my content type, I can already notice that Title is only part of the Item content type.
After removing this content type, this field was gone.