扩展字段在 SharePoint 列表上无法完全发挥作用
Expanding fields not working fully on SharePoint Lists
我正在关注 Get metadata for a list 的文档。
使用 PowerShell 或 Graph 资源管理器进行查询无法完全展开 SharePoint 列表中项目的字段。
这方面的一个示例是名为 Responsible
的查找字段,它在 Azure Active Directory 中查找用户(或者在 SharePoint 术语中,该列是 Person or Group
列,仅限于人员)。
一旦通过 GUI 选择,它就会填充一个显示名称(尽管我希望在后端存储更多明确的信息,例如 UPN
)。
使用以下形式查询图表 API 时:
$Uri = "https://graph.microsoft.com/v1.0/sites/$($SPSite.id)/lists/$($ServiceList.id)/items?expand=fields"
$Data = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri $Uri -Method Get -ErrorAction Stop
我们得到这样的结果:
@odata.etag : "REMOVED"
Title : Storage Platform
Description : Central storage platform
ResponsibleLookupId : 14
Responsible2LookupId : 13
AccountableLookupId : 3
Features : NFS
AudienceLookupId : 92
RequestProcess : {@{LookupId=1; LookupValue=Service Desk}}
Support : {@{LookupId=1; LookupValue=Service Desk}}
AvailabilityLookupId : 1
DependsOn : {}
O365GroupLookupId : 87
LifecycleStageLookupId : 2
ConsultLookupId : 88
id : 1
ContentType : Item
Modified : 2017-11-17T10:47:07Z
Created : 2017-11-17T10:47:07Z
_UIVersionString : 1.0
Attachments : False
Edit :
LinkTitleNoMenu : Storage Platform
LinkTitle : Storage Platform
ItemChildCount : 0
FolderChildCount : 0
_ComplianceFlags :
_ComplianceTag :
_ComplianceTagWrittenTime :
_ComplianceTagUserId :
可以看到字段ResponsibleLookupId
只是给出了一个14
的值,这个值是没有用的。其他字段 link 到 Office 365 组,但同样是 return 值。因此,不可能 link 任何这些数据到 users/groups 并且价值非常有限,除非通过门户查看它。
我们如何扩展这些数据? API 稍后会提供它,还是我们必须执行进一步查找?
默认情况下,Microsoft Graph 将 return LookupId
查找字段。您可以通过在 $select
参数中专门请求该字段来要求它提供实际值。
使用以下查询将 return displayName
而不是 Responsible
的 LookupId
:
...items?expand=fields($select=Responsible)
您可以在 FieldValueSet 的文档中了解其工作原理。
至于 returning userPrincipalName
,目前您无法控制它 return 的值(它是 LookupId
或 displayName
) .我建议访问 UserVoice 并添加您的建议。
我正在关注 Get metadata for a list 的文档。
使用 PowerShell 或 Graph 资源管理器进行查询无法完全展开 SharePoint 列表中项目的字段。
这方面的一个示例是名为 Responsible
的查找字段,它在 Azure Active Directory 中查找用户(或者在 SharePoint 术语中,该列是 Person or Group
列,仅限于人员)。
一旦通过 GUI 选择,它就会填充一个显示名称(尽管我希望在后端存储更多明确的信息,例如 UPN
)。
使用以下形式查询图表 API 时:
$Uri = "https://graph.microsoft.com/v1.0/sites/$($SPSite.id)/lists/$($ServiceList.id)/items?expand=fields"
$Data = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri $Uri -Method Get -ErrorAction Stop
我们得到这样的结果:
@odata.etag : "REMOVED"
Title : Storage Platform
Description : Central storage platform
ResponsibleLookupId : 14
Responsible2LookupId : 13
AccountableLookupId : 3
Features : NFS
AudienceLookupId : 92
RequestProcess : {@{LookupId=1; LookupValue=Service Desk}}
Support : {@{LookupId=1; LookupValue=Service Desk}}
AvailabilityLookupId : 1
DependsOn : {}
O365GroupLookupId : 87
LifecycleStageLookupId : 2
ConsultLookupId : 88
id : 1
ContentType : Item
Modified : 2017-11-17T10:47:07Z
Created : 2017-11-17T10:47:07Z
_UIVersionString : 1.0
Attachments : False
Edit :
LinkTitleNoMenu : Storage Platform
LinkTitle : Storage Platform
ItemChildCount : 0
FolderChildCount : 0
_ComplianceFlags :
_ComplianceTag :
_ComplianceTagWrittenTime :
_ComplianceTagUserId :
可以看到字段ResponsibleLookupId
只是给出了一个14
的值,这个值是没有用的。其他字段 link 到 Office 365 组,但同样是 return 值。因此,不可能 link 任何这些数据到 users/groups 并且价值非常有限,除非通过门户查看它。
我们如何扩展这些数据? API 稍后会提供它,还是我们必须执行进一步查找?
默认情况下,Microsoft Graph 将 return LookupId
查找字段。您可以通过在 $select
参数中专门请求该字段来要求它提供实际值。
使用以下查询将 return displayName
而不是 Responsible
的 LookupId
:
...items?expand=fields($select=Responsible)
您可以在 FieldValueSet 的文档中了解其工作原理。
至于 returning userPrincipalName
,目前您无法控制它 return 的值(它是 LookupId
或 displayName
) .我建议访问 UserVoice 并添加您的建议。