Community
Showing results for 
Search instead for 
Do you mean 
Reply

OData filter on Opportunity status..

Highlighted
Copper Contributor
Posts: 191
Country: Netherlands

OData filter on Opportunity status..

Why can't I filter on it? ?$filter=status eq 0 (for Open) or $filter=status eq 1 (for ClosedLost) does not work.

Greetings,

ACT Certified Consultants
TendenZ
the Netherlands
Employee
Posts: 118
Country: USA

Re: OData filter on Opportunity status..

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.

Copper Contributor
Posts: 191
Country: Netherlands

Re: OData filter on Opportunity status..

[ Edited ]

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?

 

Greetings,

ACT Certified Consultants
TendenZ
the Netherlands
Employee
Posts: 118
Country: USA

Re: OData filter on Opportunity status..

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