Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to query open opportunities, but do not know the api name of the field. In the Opportunities report one can set Opportunity status in the top middle to be Closed, Closed Won, Open, or Any. StageName does not have the Open value. So the query "SELECT AccountId, MRR__c, from Opportunity where StageName='Open' returns nothing. Help appreaciated.

enter image description here

share|improve this question
up vote 3 down vote accepted

Stagename does not have an value = "open" The standard values are

Needs Analysis
Value Proposition
Decision Makers Perception Analysis
Proposal/Price Quote Negotiation/Review Closed Won
Closed Lost

If you are referring to the status you need to do

SELECT Id, Name FROM Opportunity WHERE IsClosed = FALSE 

The above query gives you all open opptys.

Refer here : How can i query for the type in opportunity stage?

This doc provides more info on OpportunityStage

share|improve this answer

Best way to check field names that you dont know is to go to the record page, and click on the view for the field. Your click order should be: setup>customize>opportunities>fields>status. On that page, you will see the Field Name, Field Label, and the API Name. You can use this to determine what name to use when interacting with the data. For example, my status fields API name is Status_Del__c. The __c is important, its what tells salesforce this is a custom object. This will be placed in a query as so:

[SELECT AccountId, MRR__c FROM Opportunity WHERE Status_del__c='Open']

You also have a extra , in the query- you'll want to remove that. Make sure you're querying the right fields, as well.

share|improve this answer

You can query on Opportunity Object referring to all of the Fields that you expect to see in reporting. Later, you can then apply aggregates (called bucketing in a standard report) to what's needed for the calculations in your report.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.