In Apex, I need to get a list of the Opportunity stages that are closed. These are stages that, in setup, are of the type "Closed/Won" or "Closed/Lost".

I can get a list of stage names using:

Opportunity.StageName.getDescribe().getPicklistValues()

This returns a List of Schema.PicklistEntry objects, but they do not indicate the type of stage.

有帮助吗?

解决方案

For that you will have to query the OpportunityStage table, it has fields that flag isWon & isClosed (amongst other things) for each option.

Such a query would look like this:

[SELECT Id, ApiName FROM OpportunityStage WHERE IsWon = true AND IsClosed = true]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top