Sunday, January 5, 2014

"This field can have no more than 255 characters." Error in Multiline Text Columns

Getting  "This field can have no more than 255 characters." error on SharePoint Multiple lines of text  columns?


Well, the fix is simple, we've the property  "Allow Unlimited length in document libraries" on Multiple lines of text fields. Once enabled, technically it can hold content up to 2 GB.
This field can have no more than 255 characters

We can also set this property programmatically either with C# or PowerShell:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Get-SPSite cmdlet for MOSS 2007
function global:Get-SPSite($url)
 {
    return new-Object Microsoft.SharePoint.SPSite($url)
 }

#Get-SPWeb cmdlet for MOSS 2007
Function global:Get-SPWeb($url)
{
  $site= New-Object Microsoft.SharePoint.SPSite($url)
        if($site -ne $null)
            {
               $web=$site.OpenWeb();
       
            }
    return $web
}
  
  #Parameters
  $web = Get-SPweb "http://sharepoint.crescent.com/regions/emea/se/"
  $ListName = "Employee of the Month"
  $FieldName = "Desciption"
 
  #Get the List 
  $list = $web.lists[$ListName]
 
  #Set the "Allow unlimited length in document libraries" option to true programmatically
  $list.Fields[$FieldName].UnlimitedLengthInDocumentLibrary= $true
 
  #Update the Field
  $list.Fields[$FieldName].update()

C# code:
    
    static void Main(string[] args)
        {
            SPSite mySite = new SPSite("http://sharepoint.crescent.com/regions/emea/se/");
            SPWeb myWeb = mySite.OpenWeb();

            SPList myList = myWeb.Lists["Employee of the Month"];
            SPField myField = myList.Fields["Description"];

            ((SPFieldMultiLineText)myField).UnlimitedLengthInDocumentLibrary = true;
            myField.Update();
        }

Unfortunately, in some of the OOTB list fields, "Allow Unlimited length in document libraries" property is not included in the field definition. E.g. "Description" field in SharePoint picture libraries! What's the workaround? Create a New multiline column and copy values from the existing OOTB column!



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...