无法在$ filter中使用sharepoint查找字段:列' XXX'不存在。它可能已被其他用户删除

时间:2017-12-11 12:28:38

标签: rest sharepoint sharepoint-online

我通过访问:

来检查字段

_api/web/lists/getByTitle('My%20List')/fields

我看到了这个:

<entry>
  <id>_api/Web/Lists(guid'ef4ce2a5...')/Fields(guid'a075c4c0...')</id>
  <category term="SP.FieldLookup" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <link rel="edit" href="Web/Lists(guid'ef4ce2a5...')/Fields(guid'a075c4c0-2ccf...')" />
  <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/DescriptionResource" type="application/atom+xml;type=entry" title="DescriptionResource" href="Web/Lists(guid'ef4ce2a5...')/Fields(guid'a075c4c0-...')/DescriptionResource" />
  <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/TitleResource" type="application/atom+xml;type=entry" title="TitleResource" href="Web/Lists(guid'ef4ce2a5...')/Fields(guid'a075c4c0-...')/TitleResource" />
  <title />
  <updated>2017-12-11T11:38:44Z</updated>
  <author>
     <name />
  </author>
  <content type="application/xml">
     <m:properties>
        <d:AutoIndexed m:type="Edm.Boolean">false</d:AutoIndexed>
        <d:CanBeDeleted m:type="Edm.Boolean">true</d:CanBeDeleted>
        <d:ClientSideComponentId m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:ClientSideComponentId>
        <d:ClientSideComponentProperties m:null="true" />
        <d:CustomFormatter m:null="true" />
        <d:DefaultFormula m:null="true" />
        <d:DefaultValue m:null="true" />
        <d:Description />
        <d:Direction>none</d:Direction>
        <d:EnforceUniqueValues m:type="Edm.Boolean">false</d:EnforceUniqueValues>
        <d:EntityPropertyName>Applicant_x0027_s_x0020_name_x002</d:EntityPropertyName>
        <d:Filterable m:type="Edm.Boolean">true</d:Filterable>
        <d:FromBaseType m:type="Edm.Boolean">false</d:FromBaseType>
        <d:Group>Custom Columns</d:Group>
        <d:Hidden m:type="Edm.Boolean">false</d:Hidden>
        <d:Id m:type="Edm.Guid">a075c4c0-...</d:Id>
        <d:Indexed m:type="Edm.Boolean">false</d:Indexed>
        <d:InternalName>Applicant_x0027_s_x0020_name_x002</d:InternalName>
        <d:JSLink>clienttemplates.js</d:JSLink>
        <d:PinnedToFiltersPane m:type="Edm.Boolean">false</d:PinnedToFiltersPane>
        <d:ReadOnlyField m:type="Edm.Boolean">true</d:ReadOnlyField>
        <d:Required m:type="Edm.Boolean">false</d:Required>
        <d:SchemaXml>&lt;Field Type="Lookup" DisplayName="Sponsor 1" List="{1ebba953-...}" WebId="c4e999e3-07ac-4fc8-bd12-f0849d3ab28f" ShowField="Sponsor_x0020_1" FieldRef="3392bcae-4c67-470b-a56a-51d404eb94eb" ReadOnly="TRUE" UnlimitedLengthInDocumentLibrary="FALSE" ID="{a075c4c0-...}" SourceID="{ef4ce2a5...}" StaticName="Applicant_x0027_s_x0020_name_x002" Name="Applicant_x0027_s_x0020_name_x002" Version="6" Required="FALSE" Group="Custom Columns" /&gt;</d:SchemaXml>
        <d:Scope>/sites/MTA/Lists/Sponsors feedback</d:Scope>
        <d:Sealed m:type="Edm.Boolean">false</d:Sealed>
        <d:ShowInFiltersPane m:type="Edm.Int32">0</d:ShowInFiltersPane>
        <d:Sortable m:type="Edm.Boolean">true</d:Sortable>
        <d:StaticName>Applicant_x0027_s_x0020_name_x002</d:StaticName>
        <d:Title>Sponsor 1</d:Title>
        <d:FieldTypeKind m:type="Edm.Int32">7</d:FieldTypeKind>
        <d:TypeAsString>Lookup</d:TypeAsString>
        <d:TypeDisplayName>Lookup</d:TypeDisplayName>
        <d:TypeShortDescription>Lookup (information already on this site)</d:TypeShortDescription>
        <d:ValidationFormula m:null="true" />
        <d:ValidationMessage m:null="true" />
        <d:AllowMultipleValues m:type="Edm.Boolean">false</d:AllowMultipleValues>
        <d:DependentLookupInternalNames m:type="Collection(Edm.String)" />
        <d:IsDependentLookup m:type="Edm.Boolean">true</d:IsDependentLookup>
        <d:IsRelationship m:type="Edm.Boolean">false</d:IsRelationship>
        <d:LookupField>Sponsor_x0020_1</d:LookupField>
        <d:LookupList>{1ebba953-...}</d:LookupList>
        <d:LookupWebId m:type="Edm.Guid">c4e999e3-07ac-4fc8-bd12-f0849d3ab28f</d:LookupWebId>
        <d:PrimaryFieldId>3392bcae-4c67-470b-a56a-51d404eb94eb</d:PrimaryFieldId>
        <d:RelationshipDeleteBehavior m:type="Edm.Int32">0</d:RelationshipDeleteBehavior>
        <d:UnlimitedLengthInDocumentLibrary m:type="Edm.Boolean">false</d:UnlimitedLengthInDocumentLibrary>
     </m:properties>
  </content>

但是当我尝试在查询中使用它时

items?$expand=FieldValuesAsText&$filter=(Applicant_x0027_s_x0020_name_x002%20eq%20%27liero%27)

或:

items?$filter=(Applicant_x0027_s_x0020_name_x002%20eq%20%27liero%27)

我收到错误:

<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
   <m:code>-2146232832, Microsoft.SharePoint.SPException</m:code>
   <m:message xml:lang="en-US">Column 'Applicant_x0027_s_x0020_name_x002' does not exist. It may have been deleted by another user.</m:message>
</m:error>

我注意到,结果中包含lookupfieldid:

<d:Applicant_x0027_s_x0020_nameId m:type="Edm.Int32">9402</d:Applicant_x0027_s_x0020_nameId>

但我需要基于价值的过滤器,而不是ID。

1 个答案:

答案 0 :(得分:0)

尝试以下端点:

/_api/web/lists/getByTitle('My List')/items?
$select=Title,Applicant_x0027_s_x0020_name/Title
&$expand=Applicant_x0027_s_x0020_name
&$filter=Applicant_x0027_s_x0020_name/Title eq 'liero'

有关说明 - 在下面的端点中,我们从名为Drink

的列表中获取Title字段
/items?$select=Title,Drink/Title&$expand=Drink&$filter=Drink/Title eq 'Sorbet';
  

单值查找由两个单独的字段表示   SharePoint REST服务:一个表示实际字段的字段   值,另一个代表字段名称。

参考 - Query for single value lookup