DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Access Custom Field Type Child Elements Customization

Posted by PANVEGA on August 2, 2008

In this short post I wanna show you how to access the custom field type definitions in the field type xml file. It costs me a lot time to finde a post how to access the child elements.


A field type definition is an XML file named on the pattern fldtypes*.xml that is deployed to the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML. The field types that ship with Windows SharePoint Services 3.0 are located in the FLDTYPES.XML file.

A field definition file contains the information that Windows SharePoint Services needs to correctly render the field, including its column header, on a list view page (such as AllItems.aspx).

Example of my fldtypes_custom.xml:

You can access for instance the  Name=”SelectionSet” with the

TextBox mySelectionSet.Text = Field.GetCustomProperty(“SelectionSet”).ToString();

<Field Name=”TypeName”>MyPeoplePicker</Field>
<Field Name=”ParentType”>Text</Field>
<Field Name=”TypeDisplayName”>Custom PeoplePicker</Field>
<Field Name=”TypeShortDescription”>Custom PeoplePicker</Field>
<Field Name=”UserCreatable”>TRUE</Field>
<Field Name=”ShowOnListCreate”>TRUE</Field>
<Field Name=”ShowOnSurveyCreate”>TRUE</Field>
<Field Name=”ShowOnDocumentLibrary”>TRUE</Field>
<Field Name=”ShowOnColumnTemplateCreate”>TRUE</Field>
<Field Name=”Sortable”>TRUE</Field>
<Field Name=”Filterable”>TRUE</Field>
<Field Name=”FieldTypeClass”>PeoplePicker.PeoplePickerField, PeoplePicker,
Version=, Culture=neutral, PublicKeyToken=XXXXXXXXXXX</Field>
<Field Name=”SQLType”>nvarchar</Field>
<Field Type=”Choice” Name=”SelectionSet” DisplayName=”Allow selection of:” Format=”RadioButtons”>
<Default>People only</Default>
<CHOICE>People only</CHOICE>
<CHOICE>People and Groups</CHOICE>
<RenderPattern Name=”DisplayPattern”>


For custom properties, the SharePoint framework creates a separate child element available in the XML structure called Customization. You can write objects to this part of the data store using the GetCustomProperty and SetCustomProperty methods.

The GetCustomProperty and SetCustomProperty methods by themselves do not cause database interaction to occur. You should call Update to persist the custom properties to the database. Updating SchemaXml directly works differently.

Changing the property updates the database immediately without the need to call Update. The second interesting point is the persistence format used by SharePoint. Internally your objects are serialized to XML using the XmlSerializer when the field settings are persisted to the database.

Before going to the XmlSerializer all reference types are converted to a string using the ToString method. (I swear I used trial and error to find this out). This means you can only store rich objects such as Array objects through your own serialization mechanism.

Setting your custom Regular Expressions

//setup regex based on custom property
Regex reg = new Regex(GetCustomProperty(”SelectionSet”).ToString(), RegexOptions.IgnoreCase);

//if the value entered does not match
if (!reg.IsMatch(textValue))
throw new SPFieldValidationException(GetCustomProperty(”ExceptionMessage”).ToString());
return textValue;

In order to recognize a custom field type, Windows SharePoint Services 3.0 must have a field type definition in a fldtypes*.xml file. You create these files in Microsoft Visual Studio as part of a custom field type project. For example, if you had a field type definition for a field type that defined an American Social Security number, you might name the XML file fldtypes_ssn_MyCompany.xml.

More Information:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: