You need to sign in to do that
Don't have an account?
caused by: System.LimitException: Too many SOQL queries: 101
I have the following custom controller class. I get the error when I have 50 or more records and it works fine with less than 50. In the constructor I do this:
public Constructor {
filteredOpportunities = [select zone__c, Opportunity.Account.Last_Name__c, Opportunity.Account.First_Name__c, SortReservationTime__c, restaurant__c, Covers_Purchased__c, Reservation_Time__c, name, Reservation_note__c, id, AVTablenumber__c, coatcheck__c, primary_acct_name__c, notes__c, c_s_d__c, coversdined__c, numberOfTaxisNeeded__c, time_arrive__c, time_sat__c, time_finished__c, no_show__c, aviary_ticket__c, tix_site_total_price__c from opportunity where Date__c = TODAY and Opportunity.RecordType.name = 'Reservation' and Covers_Purchased__c > 0 and restaurant__c = 'Aviary' Order By SortReservationTime__c ASC, Opportunity.Account.Last_Name__c ASC];
for (Opportunity opp : filteredOpportunities) {
filteredOpportunityWrappers.add(new OpportunityWrapper(opp)); }
this.controller = new ApexPages.StandardSetController(this.filteredOpportunities);
Don't write SOQL query in Constructor becoz this is a salesforce best practice. so to avoid query in constructor that's why error will be throw.
All Answers
Hi Michael,
can you please share your full controller code here?
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
Don't write SOQL query in Constructor becoz this is a salesforce best practice. so to avoid query in constructor that's why error will be throw.
Thanks I commented out that part in the constructor and it works.
In the get method for List<Opportunity> I was re-doing the same thing as in the constructor.
Hi michael,
Yes, if u want to display opportunity list means using get method,
List<Opportunity> Opp;
public List<Opportunity> getOpp()
{
Opp = [select ..............];
return Opp;
}