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
Noven GongNoven Gong 

What are the fields I can query from the Opportunity table

Hi, 

I'm using Simple Salesforce in python to get some fields needed in our analysis; however, apart from  "Name" & "ID" , is there any other variables I can add to the following query?

sf.query("SELECT ID, Name FROM Opportunity")

I am new to Salesforce and Simple Salesforce; I wish to add a time constraint in the query above so that it only returns the recent one year's data. Is there any way to implement this?

Thanks!!
DixitSDixitS
Hi Noven,

There are n no of fields in any objects based on the requirement. you can get all the standard and custom fields in the Opportunity Object. There are many other ways too, showing one easiest way: Go Developer Console >> Select  Open from the top bar >> Entity Type column select Object  >> on Entities column select Opportunity >>  Select all the fields and click on query button >>  Query will get mechanized , you can use it where you want .

it is recommended that use only those field which is needed. Let me know if you need any other help. Thanks
Deepali KulshresthaDeepali Kulshrestha
Hi Noven


There are n no of fields in any objects based on the requirement such as Close date, StageName etc.
Through this code you can find all the opportunity created by between these days.
 
public class Testdate {
    public static void test()
    {
        Date myDate = date.newinstance(2019, 8, 1);
        Date myDate2 = date.newinstance(2019, 9, 1);
        List<Opportunity> oppLst = [Select o.CreatedDate, o.Id, o.LastModifiedDate  from Opportunity o where   

o.CreatedDate >: myDate and o.CreatedDate <:  myDate2] ;
        System.debug(oppLst);
        
        
    }
    
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com