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.

Leave a Reply

Your email address will not be published.