当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] “该字段不能超过 255 个字符。”多行文本列中的错误

作者:精品下载站 日期:2024-12-14 13:42:05 浏览:15 分类:玩电脑

“该字段不能超过 255 个字符。”多行文本列中的错误


获取“此字段不能超过 255 个字符。” SharePoint 上的多行文本列出现错误?

[玩转系统] “该字段不能超过 255 个字符。”多行文本列中的错误

解决方法很简单,我们在多行文本字段上设置了“文档库中允许无限长度”属性。启用后,从技术上讲,它可以容纳高达 2 GB 的内容。

[玩转系统] “该字段不能超过 255 个字符。”多行文本列中的错误

我们还可以使用 C# 或 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 "https://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#代码:


static void Main(string[] args)
{
	SPSite mySite = new SPSite("https://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();
}

遗憾的是,在某些 OOTB 列表字段中,字段定义中不包含“文档库中允许无限长度”属性。例如。 SharePoint 图片库中的“描述”字段!解决方法是什么?创建一个新的多行列并从现有的 OOTB 列复制值!

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯