SharePoint Tip #26: Comments in Content Type Definition

We would like to bring to your attention this Blog by André
Vala. André Vala was a speaker
at the European SharePoint Conference 2011 in Berlin.

There is an issue with SharePoint 2010’s CAML parser that causes
SharePoint to ignore fields in a Content Type definition. When
defining a Content Type feature element, avoid placing comments
inside the<fieldrefs>element as that will cause SharePoint to
create the Content Type disregarding all the fields, even though
the XML is well formed.

<?xml version=”1.0″ encoding=”utf-8″ ?>
<Elements
xmlns=”http://schemas.microsoft.com/sharepoint/”>
<ContentType

ID=”0x0100C5647A362F236548B218C15302286758″
Name=”MyCT”
Description=”Simple Custom Content
Type”
Inherits=”TRUE”
Overwrite=”TRUE”
Version=”0″>
<Folder TargetName=”_cts/MyCT” />
<FieldRefs>
<FieldRef
ID=”{fa564e0f-0c70-4ab9-b863-0177e6ddd247}” Name=”Title”
/>

<!– This is a comment
–>

<FieldRef
ID=”{b402db15-ee44-4ec4-89e3-23e10a8fc64c}” Name=”My_x0200_Field”
/>
<FieldRef
ID=”{538c71e4-8650-4ce7-b021-920effa66346}” Name=”Status”
/>
</FieldRefs>
</ContentType>
</Elements>

The Content Type feature element above will cause the Content
Type to be created with only the Title field, which is inherited
from the parent Content Type. All the fields referenced in this
Content Type definition will be ignored.

Book your place at the European SharePoint Conference Now.

Share this on...

Rate this Post:

Share:

Topics:

General