Wednesday, June 24, 2020

D365FO | OData - How to filter on Enum Properties

Problem

You are querying the data from D365FO via OData and try something as follows.

 https://aaaaaa.sandbox.ax.dynamics.com/data/PartyLocationPostalAddressesV2?$top=100&$filter=IsPrimary eq 'Yes'   
 or  
 https://aaaaaa.sandbox.ax.dynamics.com/data/PartyLocationPostalAddressesV2?$top=100&$filter=IsPrimary eq True   

Then you got the error.

 <Message>An error has occurred.</Message>  
 <ExceptionMessage>A binary operator with incompatible types was detected. Found operand types 'Microsoft.Dynamics.DataEntities.NoYes' and 'Edm.Boolean' for operator kind 'Equal'.</ExceptionMessage>  
 <ExceptionType>Microsoft.OData.Core.ODataException</ExceptionType>  

Many thanks to..
 


Solution

 https://aaaaaa.sandbox.ax.dynamics.com/data/PartyLocationPostalAddressesV2?$top=100&$filter=IsPrimary eq Microsoft.Dynamics.DataEntities.NoYes'Yes'  

Until the next post!