08-30-2018 02:25 AM
Why can't I filter on it? ?$filter=status eq 0 (for Open) or $filter=status eq 1 (for ClosedLost) does not work.
11-02-2018 12:29 PM
The correct way to filter would be:
api/opportunities?$filter=(status eq 'Open')
api/opportunities?$filter=(status eq '0')
api/opportunities?$filter=(status eq Act.Framework.Opportunities.OpportunityStatus'0')
However, for this enum type there is no IEdmModel so it does not work. I have corrected the API to fix this issue. Will be in the next release.
02-22-2019 12:28 AM - edited 02-22-2019 12:29 AM
Hi, this still seems not to work (version 1.0.317.0).
I have a simple database with 1 opportunity with status 'Closed - Won' and 9 'Open'.
Request: /act.web.api/api/opportunities?$filter=(status eq 'Open')
Response:
[] // should be 9 items
Request: /act.web.api/api/opportunities?$filter=(status eq '1')
Response:
[] // should be 9 items
Request: /act.web.api/api/opportunities?$filter=(status eq Open)
Response:
A binary operator with incompatible types was detected. Found operand types 'Act.Framework.Opportunities.OpportunityStatus' and 'Edm.Int32' for operator kind 'Equal'.
Request: /act.web.api/api/opportunities?$filter=(status eq Act.Framework.Opportunities.OpportunityStatus.Open)
Response:
The child type 'Act.Framework.Opportunities.OpportunityStatus.Open' in a cast was not an entity type. Casts can only be performed on entity types.
When will this be fixed?
02-22-2019 07:46 AM
I will take a look at fixing this issue, but you can get it to work by fully qualifying the enumeration. I know that this isn't documented, but make the call like this:
api/opportunities?$filter=(status eq Act.Framework.Opportunities.OpportunityStatus'Open')
OData requires enumeration to be fully qualified the enum, but I can't expect clients (like yourself) to know the namespace, so I will modify the API to lookup and per-qualify the namespace. For know just use what I have provided above until I can get a fix for this. The docs and the result is wrong as well, it should be Open not 0 in the result, but I don't know if I can change that without breaking versioning. I will run this by Jeff to see if we can change that.
The Status Namespace is: Act.Framework.Opportunities
The types are 'Open', 'Won', 'Lost', and 'Inactive'.
If you have any other enumerations that you need the namespace for just let me know, Sorry about this