如何解决如何通过使用CSOM传递查找值来在sharepoint中设置查找列?
如何通过使用CSOM Powershell传递查找值来在共享点中设置查找列?
我有一个列表,我想在其中插入一个带有查找值的查找列的项目,如何使用CSOM Power Shell实现此目的?
解决方法
您可以通过以下代码插入项目并设置其查找列:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Mysite URL
$site = 'https://abc.sharepoint.com/sites/s01'
#Admin User Principal Name
$admin = 'admin@abc.onmicrosoft.com'
#Get Password as secure String
$password = ConvertTo-SecureString "xxxxxxxxx" -AsPlainText -Force
#Get the Client Context and Bind the Site Collection
$context = New-Object Microsoft.SharePoint.Client.ClientContext($site)
#Authenticate
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($admin,$password)
$context.Credentials = $credentials
$list = $context.Web.Lists.GetByTitle('SeriesArticle')
$context.Load($list)
$context.ExecuteQuery()
$listItemInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$NewItem = $list.AddItem($listItemInfo)
$NewItem["Title"]="t001"
# create an Object[] and add FieldLookupValue instances
$lookupValueCollection = @()
$lookupValue = New-Object Microsoft.SharePoint.Client.FieldLookupValue
$lookupValue.LookupId = 4
$lookupValueCollection += $lookupValue
$lookupValue = New-Object Microsoft.SharePoint.Client.FieldLookupValue
$lookupValue.LookupId = 5
$lookupValueCollection += $lookupValue
# convert the Object[] to a FieldLookupValue[]
$mvLookup = [Microsoft.SharePoint.Client.FieldLookupValue[]]$lookupValueCollection
$item["MultiValueLookupColumnName"] = $mvLookup
$item.Update()
$ctx.ExecuteQuery()
更多参考:
BR
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。