问题描述
我无法在SharePoint 2013列表中选择查找字段.我也无法根据查找"字段进行过滤.
I can't select look up field in my SharePoint 2013 List.also I can't filter base on a Look up field.
例如,我有一个带有名称测试的列表,并且此列表包含以下字段:标题,公司,省公司和省份是我要根据省份筛选的查找字段,这是一个查找字段使用REST查询会给出错误:
for example I have List with Name Test and this list has fields: Title, Company, Provincethe Company and Province is look up fields I want to filter based on Province which is a look up fieldusing REST query it gives error:
我的查询:
https://TestServer/sites/AIB/OBC/_api/web/lists/getByTitle('Test')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq 'ABC'
当我将URL放入浏览器进行测试时,它会给出错误:
it gives error when I put the URL in My browser for testing it gives the blow error:
<m:message xml:lang="en-US">The field or property 'Province' does not exist.</m:message>
如何基于SharePoint 2013 REST中的查找字段进行筛选?
How to filter based on a look up field in SharePoint 2013 REST ?
推荐答案
如何使用SharePoint REST按查找字段值进行过滤
假定一个Contacts
列表包含一个名为Province
How to filter by lookup field value using SharePoint REST
Assume a Contacts
list that contains a lookup field named Province
选项1
将查找列添加到列表时,其ID
可以通过REST自动访问.例如,将名为Province
的字段添加到列表中时,可以设置或通过列表项的ProvinceId
属性获取Province Id
.
When a lookup column is being added into list, its ID
become accessible automatically via REST. For example, when the field named Province
is added into List, Province Id
could be set or get via ProvinceId
property of List Item.
以下查询演示了如何通过查找字段ID (在我们的示例中为Province Id
)过滤列表项:
The following query demonstrate how to filter list items by lookup field Id (Province Id
in our case):
/_api/web/lists/GetByTitle('<list title>')/items?$filter=LookupField eq <ProvinceId>
其中<ProvinceId>
是省份ID
选项2
为了按查找值进行过滤,查询应包含$expand
查询选项以检索投影的字段(如Province Title
).下面的示例演示如何按查找字段值(在本例中为Province Title
)进行过滤:
In order to filter by lookup value, the query should contain $expand
query option to retrieve projected fields (like Province Title
). The following example demonstrates how to filter by lookup field value (by Province Title
in our case):
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq <ProvinceTitle>
其中<ProvinceTitle>
是省份Title
这篇关于SharePoint 2013 REST如何选择查找字段并根据查找字段进行筛选?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!