现在的位置: 首页 > 综合 > 正文

深入浅出SharePoint——更新计算列

2013年06月24日 ⁄ 综合 ⁄ 共 606字 ⁄ 字号 评论关闭

在SharePoint2007下测试通过。

使用SharePoint对象模型:

SPFieldCollection collFields = list.Fields;
//Update the calculated column
if (collFields.ContainsField("Document ID"))
{
    collFields["Document ID"].Update();
}

 

使用Powershell:

[System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)
#This will get the site URL
$siteUrl= http://Site URL
#This is to get the WebApp
$webName = "WebAppName"
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spWeb = $spSite.OpenWeb()
Write-Host $spList = $spWeb.Lists["ListName"]
Write-Host {list found}
$collFields = $spList.Fields[""];
$collFields.Formula= "=[Field1]+[Field1No]+[Field45No]"
$collFields.update();

 

抱歉!评论已关闭.