Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / How to filter Odata wi...
Finance forum
Answered

How to filter Odata with multiple enum value D365

Posted on by 118

Hi All,

How could i filter odata with multiple enum value? I tried using this filter on the postman and not success

$filter=Type eq Microsoft.Dynamics.DataEntities.RateType'OC' And Type eq Microsoft.Dynamics.DataEntities.RateType'C'

Thanks 

Masha

  • it.dev Profile Picture
    it.dev 118 on at
    RE: How to filter Odata with multiple enum value D365

    Hi All,

    Finally the filter works after i synchronize the db, i dont't know if that relates to this issue but hopefully the filter run already with OR like this <MyUrl>/data/RateTypeEntity?cross-company=true&$filter=Type eq Microsoft.Dynamics.DataEntities.RateType'OC' or Type eq Microsoft.Dynamics.DataEntities.RateType'C'

    Thanks,

    Masha

  • it.dev Profile Picture
    it.dev 118 on at
    RE: How to filter Odata with multiple enum value D365

    Hi Uday,

    I already used the enum name

    Thanks,

    Masha

  • udaY-ch Profile Picture
    udaY-ch 4,616 on at
    RE: How to filter Odata with multiple enum value D365

    Hi,

    Try using enumValueName than enum value label.

    Uday

  • it.dev Profile Picture
    it.dev 118 on at
    RE: How to filter Odata with multiple enum value D365

    Hi Sergei and Deekshit,

    Still not success either use AND / OR. Here's the error i got in the postman

    "Syntax error at position 90 in 'Type eq Microsoft.Dynamics.DataEntities.RateType'OC' OR Type eq Microsoft.Dynamics.DataEntities.RateType'C''."

    Thanks,

    Masha

  • Suggested answer
    RE: How to filter Odata with multiple enum value D365

    If you want to return values corresponding to both enums, then you would use the binary "OR" which roughly translates to "AND" in english :)

    If you use AND in your expression (URL) then its looking to see if there is a match that satisfies RateType=OC and RateType=C for the same record.

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,083 on at
    RE: How to filter Odata with multiple enum value D365

    Hi Masha,

    But it's still using 'And' keyword.

    Try to use that example <MyUrl>/data/RateTypeEntity?cross-company=true&$filter=Type eq Microsoft.Dynamics.DataEntities.RateType'OC' or Type eq Microsoft.Dynamics.DataEntities.RateType'C'

  • it.dev Profile Picture
    it.dev 118 on at
    RE: How to filter Odata with multiple enum value D365

    Hi Sergei,

    this is my url

    <MyUrl>/data/RateTypeEntity?$filter=Type eq Microsoft.Dynamics.DataEntities.RateType'OC' And Type eq Microsoft.Dynamics.DataEntities.RateType'C'

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,083 on at
    RE: How to filter Odata with multiple enum value D365

    Hi Masha,

    Could you, please, provide the full url you are using?

    At least for me 'or' condition is working fine, maybe you have other parameters in the url?

    <MyUrl>/data/SalesOrderHeadersV2?$filter=SalesOrderStatus eq Microsoft.Dynamics.DataEntities.SalesStatus'Backorder' or SalesOrderStatus eq Microsoft.Dynamics.DataEntities.SalesStatus'Canceled'

  • it.dev Profile Picture
    it.dev 118 on at
    RE: How to filter Odata with multiple enum value D365

    Hi Sergei,

    Yes i can get the data if filter only one of the enum

    Thanks

    Masha

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,083 on at
    RE: How to filter Odata with multiple enum value D365

    Hi Masha,

    Do you get any data if you just filter by one of the enum value (without 'and' or 'or' condition)?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans