Wednesday, February 16, 2011

Reminder about Content Types

When constructing a ContentType in the elements file you’ll reference to existing Site Columns.

Example Content Type:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x010055180D0A5202894F9E64FC9D6D4A86B7" Name="EditionCT" Group="Test" Inherits="true" Hidden="false" ReadOnly="false" Sealed="false">
<FieldRefs>
<FieldRef ID="71316cea-40a0-49f3-8659-f0cefdbdbd4f" Name="ArticleStartDate" DisplayName="Article Date" />
<FieldRef ID="64cd368d-2f95-4bfc-a1f9-8d4324ecb007" Name="StartDate" DisplayName="Start Date" />
<FieldRef ID="919f30d5-31f1-478f-bda5-84f595340392" Name="EndDate1" DisplayName="End Date" />
<FieldRef ID="d2132670-ec6e-4fc7-af38-0ca09a364b80" Name="Send" DisplayName="Send" />
<FieldRef ID="8adac618-8387-4c39-ad9a-ed6c17084d3a" Name="Send_x0020_Date" DisplayName="Send Date" />
<FieldRef ID="d1fc4f17-b0f7-4177-9f94-5b32cbdd2d5a" Name="Send_x0020_To" DisplayName="Send To" />
<FieldRef ID="cc69c48f-5536-4478-9172-a79468a32afa" Name="FinalSubmissionDate" DisplayName="FinalSubmissionDate" />
<FieldRef ID="cd8a6351-3235-4eb2-857d-87975bb8cb90" Name="ReminderDays" DisplayName="ReminderDays" />
<FieldRef ID="bcf32df2-5191-43d7-a1a4-fdb17acccb98" Name="SendReminderAt" DisplayName="SendReminderAt" />
</FieldRefs>
</ContentType>
</Elements>
 
Example SiteColumn:
<Field Type="Boolean" DisplayName="Send" Group="Base" EnforceUniqueValues="FALSE" Indexed="FALSE" ID="{d2132670-ec6e-4fc7-af38-0ca09a364b80}" SourceID="{b6366c11-b4ce-408c-8175-952b9a7800d4}" StaticName="Send" Name="Send" ShowInNewForm="FALSE" ShowInEditForm="FALSE" />
 
One thing did cost me a few hours to find out. When activating the feature the Content Type EditionCT was corrupt. It showed the Send column was of type DateTime, it was defined as a Boolean. In the Site Column overview it did show as a boolean. So only the content type was corrupted.
Site Column:
image
 
Content Type in Site Settings (nothing wrong, you think):
image
 
Content Type in SharePoint Manager 2010 (its corrupt):
image
 
Content Type when added to a list (also corrupted):
image
 
 
Than I noticed the ArticleStartDate was a site column from the Publishing framework. This site collection feature wasn’t activated and so that appropriate fields were not available, one of them was the ArticleStartDate. Strange thing was that SharePoint didn’t report an error when constructing the content type, but just corrupted the Content Type.
 
So keep in mind to have the fields available when provisioning the Content Type, and as you can see, strange things can happen.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.