Filter for enum fields in OData service

It took me a while to figure out how to filter AX (Operations) enum fields in the URL for OData service (I was using Get records in Flow). For example, let’s say I wanted to get sales orders with status = open order.

After a few failed attempts, I actually used classes generated by OData Client Code Generator, constructed a LINQ query and ran it.

context.SalesOrderHeaders.Where(h => h.SalesOrderStatus == SalesStatus.Backorder).ToArray();

Then I intercepted the URL in an event handler for SendingRequest2 and finally got the answer. The filter must be set in this way:

SalesOrderStatus eq Microsoft.Dynamics.DataEntities.SalesStatus'Backorder'

No wonder I didn’t guess it.


  1. Thanks, was looking for this for a long time. Terrible documentation from microsoft.

  2. Thanks for posting this Martin. It had me stumped for a few days trying to make sense of the error message ‘A binary operator with incompatible types was detected’

  3. When i tried the same i got the error saying that

    The string ‘xx” is not a valid enumeration type constant

    • There is no ‚xx“ string in my blog post. I suggest you review your code and if you can’t find any problem, create a thread in a discussion forum, share your code and we can discuss it there.

Comments are closed.