【问题标题】:Finding all of the values in a lookup field in SharePoint Online with PowerShell使用 PowerShell 在 SharePoint Online 中查找查找字段中的所有值
【发布时间】:2021-06-20 04:06:57
【问题描述】:

所以我一直在玩这个。我正在使用 SharePoint PnP 模块来尝试自动执行一些 SharePoint 任务。

基本上我正在尝试将新项目添加到具有查找字段的列表中。我现在的症结在于尝试添加列表中尚不存在但存在于查找字段中的查找字段值。

我似乎无法找到一种方法来捕获查找字段本身中存在的内容,只是列表中查找字段中当前存在的内容。

$List_SkillsPerAgent = Get-PnPList -Identity SkillsPerAgent

$DCISkill = (Get-PnPListItem -List $List_SkillsPerAgent -Fields "wsp_ucc_spa_skill").FieldValues.wsp_ucc_spa_skill | Where-Object { $PSItem.LookupValue -eq 'DCISkill' } | Select-Object LookupId -First 1

$PhoneQueue = (Get-PnPListItem -List $List_SkillsPerAgent -Fields "wsp_ucc_spa_skill").FieldValues.wsp_ucc_spa_skill | Where-Object { $PSItem.LookupValue -eq $Queue.Replace('_', ' ') } | Select-Object LookupId -First 1

$Agent = (Get-PnPListItem -List $List_SkillsPerAgent -Fields "wsp_ucc_spa_Agent").FieldValues.wsp_ucc_spa_Agent | Where-Object { $PSItem.LookupValue -eq 'sip:somefakeemail@domain.com' } | Select-Object LookupId -First 1 

前两个步骤工作正常,因为这些值已经存在于列表中,但是最后一个 'sip:somefakeemail@domain.com' 在列表中尚不存在,因此我无法使用 Get-PnpListItem 找到它的 LookupID ,但是它确实存在于查找字段 wsp_ucc_spa_Agent 中。

我尝试过使用 Get-PnpField,但还没有这样的运气。

是否可以捕获该查找字段中的所有值?

【问题讨论】:

    标签: powershell sharepoint sharepoint-online


    【解决方案1】:

    查找字段中的值存储在您引用的父列表中。捕获查找字段中的所有值。我建议你在父列表中找到它们,lookupID 应该是父列表中的 listItem id。

    【讨论】:

    • 我在父列表项中进行了更多挖掘,我想它会在这里$List.Fields 但我收到了这个错误An error occurred while enumerating through a collection: The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.. 我仍在浏览可用的属性、方法等。我找对地方了吗?
    • 你可以试试这个parnet列表来获取字段值:(Get-PnPListItem -List -Fields "FiekdName").FieldValues
    • 这就是我正在做的事情,但它不会抓取列表中尚不存在的查找字段的值。这就是我正在尝试做的。例如,有一个查找字段,其中包含 Value1、Value2 和 Value3。但是,列表中仅存在 Value1 和 Value2。有没有办法获取查找字段的所有值,即使它们不存在于列表中?
    猜你喜欢
    • 2017-12-31
    • 2017-12-14
    • 2019-07-21
    • 1970-01-01
    • 2021-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多