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
ugsfdcugsfdc 

Facing the soql limit exception while follow the best practices also ?

Hi All,
I am facing soql limit exception with best practices also, May i know the reason please.

Regards,
ugsfdc
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

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

Notes:
  • All the SOQL queries in triggers fired from one call or context will be counted against the limit of 100.
  • Salesforce cannot disable or raise the Governors Limit.

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.

Reference: https://help.salesforce.com/articleView?id=000181404&type=1 (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