Sharepoint 2010 如何为分配给查找的SharePoint 2010列指定默认值?

Sharepoint 2010 如何为分配给查找的SharePoint 2010列指定默认值?,sharepoint-2010,Sharepoint 2010,我有一个SharePoint 2010网站,并且有一列指定给查找。 我可以为列指定一个默认值吗?我们可以使用PowerShell脚本为查找列设置默认值 $web= Get-SPWeb http://sp2010 $list = $web.Lists["CustomList"] $listField = $list.Fields["TestLookup"] $listField.DefaultValue = "1" $listField.Update() 或者使用Infopath来实现它 Add

我有一个SharePoint 2010网站,并且有一列指定给查找。
我可以为列指定一个默认值吗?

我们可以使用PowerShell脚本为查找列设置默认值

$web= Get-SPWeb http://sp2010
$list = $web.Lists["CustomList"]
$listField = $list.Fields["TestLookup"]
$listField.DefaultValue = "1"
$listField.Update()
或者使用Infopath来实现它

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

$url="http://sp2010"
$userName="administrator"
$password="**"
$domain="test"
$listName="CustomList"
$fieldName="TestLookup"

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)  
$credentials = New-Object System.Net.NetworkCredential($userName,$password,$domain)   
$ctx.Credentials = $credentials

$list = $ctx.Web.Lists.GetByTitle($listName)
$field = $list.Fields.GetByTitle($fieldName)

$field.DefaultValue = "1"
$field.Update()
$ctx.ExecuteQuery()
文章

如果您想在客户端将默认值设置为lookup列,我们可以使用CSOM和PowerShell来实现它

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

$url="http://sp2010"
$userName="administrator"
$password="**"
$domain="test"
$listName="CustomList"
$fieldName="TestLookup"

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)  
$credentials = New-Object System.Net.NetworkCredential($userName,$password,$domain)   
$ctx.Credentials = $credentials

$list = $ctx.Web.Lists.GetByTitle($listName)
$field = $list.Fields.GetByTitle($fieldName)

$field.DefaultValue = "1"
$field.Update()
$ctx.ExecuteQuery()

感谢您提供PowerShell脚本示例。你可以吗?它可以在任何计算机上运行;不一定在SharePoint服务器上?我从未运行过这种类型的PowerShell scipt(关于SharePoint)。如果我修改了回复,请检查它。使用CSOM和PowerShell来实现它。