Field Type

Represents an extensible common data structure in SharePoint Products and Technologies for use in lists or other objects that can use SPField objects.

Real World Example

Your organization needs a complex structure to hold shipping addresses in a SharePoint environment that is available globally. A developer creates a field type that contains the structure and displays information for shipping addresses.

Technical Details

Custom field types are defined by .xml files that follow the naming convention fldtypes_XYZ.xml, where XYZ is the name of the field type. The .xml file describes the field type and refers to the class or assembly that contains the SPField object implementation for the field type.

Following is an example from the fldtypes_TargetTo.xml file:

<FieldTypes>
   <FieldType>
      <Field Name="TypeName">TargetTo</Field>
      <Field Name="ParentType">Note</Field>
      <Field Name="TypeDisplayName">$Resources:spscore,FieldTypes_Audience_DisplayName;</Field>
      <Field Name="TypeShortDescription">$Resources:spscore,FieldTypes_Audience_ShortDescription;</Field>
      <Field Name="UserCreatable">FALSE</Field>
      <Field Name="FieldTypeClass">Microsoft.Office.Server.WebControls.FieldTypes.SPFieldTargetTo, Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c</Field>
      <Field Name="ShowOnSurveyCreate">FALSE</Field>
      <PropertySchema>
         <Fields>
            <Field Name="AllowGlobalAudience" DisplayName="$Resources:spscore,FieldTypes_Audience_AllowGlobalAudience;" Type="Boolean"> 
               <Default>1</Default>
            </Field> 
            <Field Name="AllowDL" DisplayName="$Resources:spscore,FieldTypes_Audience_AllowDistributionList;" Type="Boolean"> 
               <Default>1</Default>
            </Field> 
            <Field Name="AllowSPGroup" DisplayName="$Resources:spscore,FieldTypes_Audience_AllowSharepointGroup;" Type="Boolean">
               <Default>1</Default>
            </Field> 
         </Fields>
      </PropertySchema>
      <RenderPattern Name="DisplayPattern">
         <Switch>
            <Expr><Column/></Expr>
            <Case Value="">$Resources:spscore,FieldTypes_Audience_NotTargeted;</Case>
            <Case Value=";;;;">$Resources:spscore,FieldTypes_Audience_NotTargeted;</Case>
            <Default>$Resources:spscore,FieldTypes_Audience_Targeted;</Default>
         </Switch>
      </RenderPattern>
   </FieldType>
</FieldTypes>

Support Details

The field type’s class must inherit from one of the base field types in Windows SharePoint Services, and must be compiled into a strong-named assembly that is deployed to the global assembly cache. Because of this, you should carefully examine the assembly for security or performance issues.