Partager via


How to change a multi line text field to allow unlimited length in a document library

There is a restriction on number of characters (255 characters) allowed for a Multi line text field added to a document library when you try to input more than 255 characters through UI.

Attaching a sample code which will help in working around the problem of restriction on number of characters (255 characters) allowed for a Multi line text field added to a document library.

SPSite mySite = new SPSite("<https://SiteURL>");

SPWeb myWeb = mySite.OpenWeb();

SPList myList = myWeb.Lists["<DOCLIBNAME>"];

SPField myField = myList.Fields["MULTILINE-FIELDNAME"];

((SPFieldMultiLineText)myField).UnlimitedLengthInDocumentLibrary = true;

myField.Update();

Comments

  • Anonymous
    November 16, 2008
    The comment has been removed

  • Anonymous
    November 17, 2008
    You should note here that when you make this change through the list setting's UI you get a warning that says "Columns with long text are not supported by most applications for editing documents and could result in loss of data.  Only remove this limit if userse will be uploading documents through the website, and not saving directly from the application." I've not experimented around with this in any client side document editors, but I'm curious if the Office 2007 suite handles longer text fields without loss.

  • Anonymous
    December 23, 2008
    I have this problem and files are only uploaded PDFs. Where do I make this change to the 'list setting's UI"? Or would it be better to use a list and attach the files to the list item instead of having a document library?