首页 > 解决方案 > Odata. Filter for some string field not working

问题描述

Im using Odata v3 with 1C Enterprise 8.3.10. on Apache Tomcat 2.2. This query http://localhost/TEST/odata/standard.odata/AccountingRegister_Типовой/Balance()?$top=1
returns such result:

<d:Result xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:type="Collection(StandardODATA.AccountingRegister_Типовой_Balance)">
    <d:element m:type="StandardODATA.AccountingRegister_Типовой_Balance">
        <d:Account_Key>8064bbd7-6b39-11e1-978d-00265502bde5</d:Account_Key>
        <d:ExtDimension1>3e0969a1-6b39-11e1-978d-00265502bde5</d:ExtDimension1>
        <d:ExtDimension1_Type>StandardODATA.Catalog_ОсновныеСредства</d:ExtDimension1_Type>
        ...            
    </d:element>
</d:Result>

when I try adding filter http://localhost/TEST/odata/standard.odata/AccountingRegister_Типовой/Balance()?$top=1&$filter=ExtDimension1 eq '3e0969a1-6b39-11e1-978d-00265502bde5'
It returns empty result.
The type of 'ExtDimension1' field is Edm.String, not guid
(from $metadata)

<ComplexType Name="AccountingRegister_Типовой_Balance">
    <Property Name="Account_Key" Type="Edm.Guid" Nullable="true"/>
    <Property Name="ExtDimension1" Type="Edm.String" Nullable="true"/>
    <Property Name="ExtDimension1_Type" Type="Edm.String" Nullable="true"/>
    ...

I also tried to filter like this:
$filter=ExtDimension1 eq guid'3e0969a1-6b39-11e1-978d-00265502bde5'
but it returns an error.

If I filter by another field (for example ExtDimension1_Type) it works correctly.
Does anybody know how to filter by 'ExtDimension1' field?

UPDATE
Here is description of Balance() function from metadata. Hope it will be usefull

<FunctionImport Name="Balance" IsBindable="true" IsSideEffecting="false" ReturnType="Collection(StandardODATA.AccountingRegister_Типовой_Balance)">
    <Parameter Name="bindingParameter" Type="StandardODATA.AccountingRegister_Типовой"/>
    <Parameter Name="AccountCondition" Type="Edm.String"/>
    <Parameter Name="Condition" Type="Edm.String"/>
    <Parameter Name="Dimensions" Type="Edm.String"/>
    <Parameter Name="ExtraDimensions" Type="Edm.String"/>
    <Parameter Name="Period" Type="Edm.DateTime"/>
</FunctionImport>

标签: restodatafiltering

解决方案


我有一个类似的问题,我找到了解决方案。

$filter=ExtDimension1 eq cast('3e0969a1-6b39-11e1-978d-00265502bde5', 'Catalog_ОсновныеСредства')

推荐阅读