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
KMK91KMK91 

Too many SOQL queries: 101 

Hi,

when we trying to open the opportunity we are getting below error . can you please suggest here 
Too many SOQL queries: 101 
An unexpected error has occurred. Your development organization has been notified.

Thanks
KMK
Best Answer chosen by KMK91
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

The following error appears when you exceed the Execution Governors Limit (you can run up to a total 100 SOQL queries in a single call or context): https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

To fix the issue, change your code so that the number of SOQL fired is less than 100.
If you need to change the context, you can use @future annotation which will run the code asynchronously.
 
Best practices to avoid exceeding the Governors Limit:

Since Apex runs on a multi-tenant platform, the Apex runtime engine strictly enforces limits to ensure code doesn't monopolize shared resources.
 
Reference: https://help.salesforce.com/articleView?id=000181404&type=1

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

The following error appears when you exceed the Execution Governors Limit (you can run up to a total 100 SOQL queries in a single call or context): https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

To fix the issue, change your code so that the number of SOQL fired is less than 100.
If you need to change the context, you can use @future annotation which will run the code asynchronously.
 
Best practices to avoid exceeding the Governors Limit:

Since Apex runs on a multi-tenant platform, the Apex runtime engine strictly enforces limits to ensure code doesn't monopolize shared resources.
 
Reference: https://help.salesforce.com/articleView?id=000181404&type=1

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer
so_mayankso_mayank
Hi KMK91,

If this error is occurring for the whole page then most probably the view action on the opportunity has been overridden with a visualforce page that is returning this error. If this a production issue. I would recommend removing the override for now and debug the visualforce page.

If this error is occurring for a part of the page, then check the opportunity page layout. For the inline visualforce page on which this error is occurring.

As for the error(Too many SOQL queries: 101), it is a standard error that occurs when you exceed the Governor limits imposed by Salesforce. You can find the details by googling. Most probably you have a SOQL query inside a for loop.