function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naresh ChandaNaresh Chanda 

how to query the opportunity stage type (Open,Closed/Won, Closed/Lost) ?

How to query the opportunity stage type (Open,Closed/Won, Closed/Lost) when an opportunity Id is given.

Also, is it possible to add more entries to Type picklist and can this field be used in integrations with other applications?
VinayVinay (Salesforce Developers) 
Hi Naresh,

Try to use below query and it should work.

SELECT id,StageName,Type FROM Opportunity where id='123'

Hope above information was helpful.
 
Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
Naresh ChandaNaresh Chanda
Hi Vinay,

Thank you for your response. I am looking for Opporuntity Stage Type - Open, Closed/Won, Closed/Lost that you see when you open the Stage field on an Opportunity object. Not the Opporunity Type field which we can retrieve directly.
VinayVinay (Salesforce Developers) 
Hi Naresh,

This is not feasible to when you query and also I haven't seen any related links which says this can be used in integrations.

Try to use lov's of picklist.

Thanks,
Vinay Kumar
Luke J FreelandLuke J Freeland
You can't query the Type directly from the Opportunity SOQL query. However, one can first query the OpportunityStage Object and then use those records with the opportunity's stage from a second query to do whatever is needed.

OpportunityStage Background Info

Querying the Opportunity Stage information using a SOQL query is possible. The OpportunityStage Object contains that information. There are many "System Objects" available that don't show up in the Object Manager in Setup. However, one can see a list of all the queryable Objects by using a tool such as Workbench.

For example, this SOQL query will query the Stage's whose Type is Closed Lost

SELECT Id, MasterLabel, ApiName, IsClosed
    FROM OpportunityStage
 WHERE IsClosed = true
       AND IsWon = false