PANVEGA’s Blog

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

SP Field Types with more than 255 Characters

Posted by PANVEGA on November 13, 2007

Problem:

When you add a custom field type that can hold more than the 255 characters you can’t use a field of type SPFieldText because it has a max length of 255 characters.

Note:

Your base class Inherits from SPFieldMultiLineText. We are only creating a singleline field, but the SPFieldText base class maps to an nvarchar(255) in the content database.  This would limit the amount of plain text that could be entered to well less than 255.  By using the SPFieldMultiLineText base class, our field is mapped to an ntext in the database.

To limit the user from entering more than 255 characters, we use the MaxLength property on the TextBox in the user control.

To solve this issue you have to do the following steps:

1.  Change the ParentType from Text to Note in you fldtypes_custom.xml file

<Field Name=”TypeName”>MyPeoplePicker</Field>
<Field Name=”ParentType”>Note</Field>
<Field Name=”TypeDisplayName”>Custom PeoplePicker</Field>
<Field Name=”TypeShortDescription”>Custom PeoplePicker</Field>

Represents whether this field type is displayed for inclusion on lists.

The possible values are exactly the same as the possible values for the Type attribute of the Field Element (List – Definition) element. If the field type is not derived from another type, then the value is an empty string:

2. That the real tricky thing, change the SQLType Field in the fldtypes_custom.xml from

<Field Name=”SQLType”>nvarchar</Field>

<Field Name=”SQLType”>ntext</Field>

Optional String. Represents the SQL data type that will be used to store the data in the content database.

However you do not use a <Field Name=”SQLType”> element in your custom field type definitions.

3.  Change the inherits in your base class from SPFieldText to SPFieldMultiLineText

That it, now you see more than 255 Charactres in your Custom Field Type

Read more:

http://msdn.microsoft.com/en-us/library/aa544201.aspx

http://sjoere.blogspot.com/2008/01/field-type-is-not-installed-properly.html

Advertisements

3 Responses to “SP Field Types with more than 255 Characters”

  1. skurocks said

    A simple workaround for the above issue using Object model

  2. skurocks said

    A simple workaround for the above issue using Object model

    http://skurocks.wordpress.com/2009/05/21/this-field-can-have-no-more-than-255-characters/

  3. PANVEGA said

    Thanks, that is a nice approach when the ObjectModel with UnlimitedLengthInDocumentLibrary attribute!!!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

 
%d bloggers like this: