使用powershell创建的查找列将具有空的“从以下位置获取信息": [英] Lookup column created using powershell will have empty "Get information from:"
问题描述
我正在内部部署SharePoint Server 2013.并且我运行以下power-shell脚本来创建查找列:-
I am working on a sharepoint server 2013 on-premise. and i run the following power-shell script to create a lookup column :-
Create site column from XML string
$web.Fields.AddFieldAsXml($fieldXML)
$site = Get-SPSite -Identity "http://***/"
$web = $site.RootWeb
#Assign fieldXML variable with XML string for site column
$fieldXML = '<Field Type="Lookup"
Name="testcol"
Description=""
DisplayName="test col"
StaticName="testcol"
Group="custom columns"
Hidden="FALSE"
Required="TRUE"
Sealed="FALSE"
ShowInDisplayForm="TRUE"
ShowInEditForm="TRUE"
ShowInListSettings="TRUE"
ShowInNewForm="FALSE"
List="Lists/dept"
ShowField="Title">
</Field>'
#Output XML to console
write-host $fieldXML
#Create site column from XML string
$web.Fields.AddFieldAsXml($fieldXML)
现在该列已成功创建.但是查找列的Get information from:
是emty,如下所示:-
now the column was created successfully. but the Get information from:
for the lookup column was emty, as follow:-
现在,我阅读了这篇文章 http://innersharepoint.blogspot.com/2013/09/fixing-blank-lookup-columns-in.html 提出了解决此问题的方法.所以我运行以下power-shell脚本:-
Now i read this article http://innersharepoint.blogspot.com/2013/09/fixing-blank-lookup-columns-in.html which propose a fix to this problem. so i run the following power-shell script:-
$site = Get-SPSite -Identity "http://***/"
$web = $site.RootWeb
$column = $web.Fields["test col"]
$lookupList = $web.Lists["dept"]
#Updating the column properties
$column.SchemaXml = $column.SchemaXml.Replace($column.LookupWebId.ToString(), $web.ID.ToString())
$column.SchemaXml = $column.SchemaXml.Replace($column.LookupList.ToString(), $lookupList.ID.ToString())
$column.Update()
write-host "Column properties have been updated"
$Web.Dispose()
现在,他/她正在链接中在列表级别更新该列,而在我的情况下,我正在网站级别更新该列..
现在在运行第二个脚本之后,site列已正确引用了dept查找列表..但是我不确定上述解决问题的上述脚本是否有效?还是我做错事了?
now in the link he/she is updating the column at the list level,, while in my case i am updating the column at the web level..
now after running the second script, the site column have referenced the dept lookup list correctly.. but i am not sure if my above script which fixed the issue is valid ? or i am doing things wrongly?
推荐答案
约翰,
尝试以下方法
site = Get-SPSite -Identity" http://***/ "
site = Get-SPSite -Identity "http://***/"
web =
这篇关于使用powershell创建的查找列将具有空的“从以下位置获取信息":的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!