SharePoint 2010 Internal Field Name Limit 32 Characters for lists… 256 characters for libraries?

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/113000

  •  29-09-2020
  •  | 
  •  

Pergunta

Recently I had a question asked of me regarding the internal field name limit in SharePoint for columns.

The user found that the same column created in a library vs. a list had different character limits.

I did some testing on this and validated that, in a regular custom list, columns added from the front end have their internal name truncated down to 32 characters after SharePoint encoding.

In a standard library, column internal names stop at 256 characters.

My questions is, is there documentation on this anywhere? Or is this just one of those undocumented 'features' of SharePoint? I can't see a logical reason why this would act like this.

Foi útil?

Solução

Looks like there is no such Public documentation available or i have seen it.

You are correct and I test it and my results are same as yours...List filed name turncated to 32 characters but Document library having bigger limit.

I tested code from this Blog post.

32 Character Limit Of SharePoint List's Internal Field Name

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

public partial class Program
{
 static void Main(string[] args)
 {
     string siteName = "http://localhost";
     string listName = "Shared Documents";
     string fieldName = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789012345";

     Console.WriteLine("Adding SPField to a SharePoint Document Library and a List with name of '{0}'", fieldName);
     Console.WriteLine();
     Console.WriteLine("Get SPField info from updated SharePoint Document Library:");
     TestFieldName(siteName, listName, fieldName);
     Console.WriteLine();

     listName = "Announcements";
     Console.WriteLine("Get SPField info from updated SharePoint List:");
     TestFieldName(siteName, listName, fieldName);

     Console.Read();
 }

 private static void TestFieldName(string siteName, string listName, string fieldName)
 {
     using (SPSite site = new SPSite(siteName))
     {
         using (SPWeb web = site.OpenWeb())
         {
             SPList list = web.Lists[listName];
             if (!list.Fields.ContainsField(fieldName))
             {
                 list.Fields.Add(fieldName, SPFieldType.Text, false);
                 list.Update();
             }
             if (list.Fields.ContainsField(fieldName))
             {
                 SPField field = list.Fields[fieldName];
                 Console.WriteLine("Display name:\t'{0}' {1}Static name:\t'{2}'",
                     field.Title, System.Environment.NewLine, field.StaticName);

                 list.Fields.Delete(fieldName);
                 list.Update();
             }
         }
     }
 }
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top