Thursday, January 1, 2009

Custom Field Type Definition

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). It also typically provides information used to render the field on the view list item page (such as DispForm.aspx). The name and description of the field type, as it appears on such UI pages as the Customize [list] page, the New Site Column, and the Create Column pages, is also configured in the field type definition. Most importantly, the definition contains information about the assembly that contains the compiled field type.
Most field type properties are required by virtually any field type, such as the name and description properties. But a field type definition can also declare and define special properties of the field type that are relevant only to columns made from fields of that particular type. These are called variable field type properties. The values of these properties are set whenever a column is created based on the field type.
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.
Field Types Definition Example
The following example defines two custom field types.




SocialSecurityNumber
Text
Social Security Number
Social Security Number (123456789, 123-45-6789)

TRUE

AdventureWorks.FieldTypes.SSNField, AdventureWorks.FieldTypes,
Version=1.0.0.0,Culture=neutral,PublicKeyToken=90734cc53324b79c







USAddress
MultiColumn
US Address
US Address(12345 NE 123 St. Redmond, WA 98052)

TRUE

AdventureWorks.FieldTypes.USAddressField, AdventureWorks.FieldTypes,
Version=1.0.0.0,Culture=neutral,PublicKeyToken=90734cc53324b79c



MaxLength="50" DisplaySize="15" Type="Text">
Redmond

MaxLength="2" DisplaySize="2" Type="Text">
WA

DisplaySize="5" Type="Text">
98052










]]>