SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Custom URL Field Types

Just a quick note on something that had me scratching my head for a couple of hours this afternoon. The task was to create a new custom field type that is based on the SPFieldUrl class. Although my fldtypes_*.xml file *looked* correct it wouldn't load. It turned out that the ParentType property value is both case-sensitive, and inconsistent. Whereas for a field that derives from SPFieldText you use set the property to "Text", if the parent type is an SPFieldUrl, you need to set the ParentType property to "URL" (all upper-case)!

So:

<FieldType>...<Field Name="ParentType">Url</Field>...</FieldType> is WRONG

<FieldType>...<Field Name="ParentType">URL</Field>...</FieldType> is RIGHT

 Gah!


Posted 04-23-2008 4:41 PM by kal

Comments

Sanjay Narang wrote re: Custom URL Field Types
on 10-15-2008 3:47 AM

Hi, can you share the fieldtypeXX.xml file used for custom URL type. I'm having issues there.

kal wrote re: Custom URL Field Types
on 10-16-2008 3:21 AM

Hi Sanjay,

This is the full content of my fldtypes_*.xml file (its quite long as it contains two field type definitions that both also include property schemas for the field types).

<?xml version="1.0" encoding="utf-8" ?>

<FieldTypes>

<FieldType>

<Field Name="TypeName">RelatedTopicLink</Field>

<Field Name="ParentType">URL</Field>

<Field Name="TypeDisplayName">Related Topic Link</Field>

<Field Name="TypeShortDescription">Related Topic Link (copied from a Related Topics field).</Field>

<Field Name="FieldTypeClass">NetworkedPlanet.SharePoint.RelatedTopicsExtensions.RelatedTopicLinkField, NetworkedPlanet.SharePoint.RelatedTopicsExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=da294bc4e1ae447d</Field>

<Field Name="UserCreatable">TRUE</Field>

<Field Name="FieldEditorUserControl">/_controltemplates/RelatedTopicLinkFieldPropertyEditor.ascx</Field>

<PropertySchema>

<Fields>

<Field Name="SourceFieldId" DisplayName="Source Field" MaxLength="255"

 DisplaySize="40" Type="Text" Hidden="TRUE">

<Default></Default>

</Field>

<Field Name="ShowDrafts" DisplayName="Copy Draft Topics" Type="Boolean" Hidden="TRUE">

<Default>FALSE</Default>

</Field>

<Field Name="ShowVersionInformation" DisplayName="Show Topic Version Information" Type="Boolean" Hidden="TRUE">

<Default>FALSE</Default>

</Field>

</Fields>

</PropertySchema>

</FieldType>

<FieldType>

<Field Name="TypeName">RelatedTopicName</Field>

<Field Name="ParentType">Text</Field>

<Field Name="TypeDisplayName">Related Topic Name</Field>

<Field Name="TypeShortDescription">Related Topic Name (copied from a Related Topics field).</Field>

<Field Name="FieldTypeClass">NetworkedPlanet.SharePoint.RelatedTopicsExtensions.RelatedTopicNameField, NetworkedPlanet.SharePoint.RelatedTopicsExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=da294bc4e1ae447d</Field>

<Field Name="UserCreatable">TRUE</Field>

<Field Name="FieldEditorUserControl">/_controltemplates/RelatedTopicNameFieldPropertyEditor.ascx</Field>

<PropertySchema>

<Fields>

<Field Name="SourceFieldId" DisplayName="Source Field" MaxLength="255"

 DisplaySize="40" Type="Text" Hidden="TRUE">

<Default></Default>

</Field>

<Field Name="ShowDrafts" DisplayName="Copy Draft Topics" Type="Boolean" Hidden="TRUE">

<Default>FALSE</Default>

</Field>

<Field Name="ShowVersionInformation" DisplayName="Show Topic Version Information" Type="Boolean" Hidden="TRUE">

<Default>FALSE</Default>

</Field>

</Fields>

</PropertySchema>

</FieldType>

</FieldTypes>

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.