Activity Forums Salesforce® Discussions System.Exception: Too many SOQL queries: 101 [duplicate]

  • Saurabh

    Member
    May 12, 2017 at 1:54 pm

    Hi Suraj

    To fix the issue related to "System.Exception: Too many SOQL queries: 101 [duplicate]", you'll need to change your code in such a way that the number of SOQL fired is less than 100. If you need to change the context then you can use @future annotation which will run the code asynchronously.

    Here are some best practices that will stop the error messages and/or help you avoid hitting the Governors Limit:
    1. Since Apex runs on a multi-tenant platform, the Apex runtime engine strictly enforces limits to ensure code doesn't monopolize shared resources. Learn about the Governors Limit.
    2. Avoid SOQL queries that are inside FOR loops.
    3. Check out the Salesforce Developer Blog where you can find Best Practices for Triggers.
    4. Review best practices for Trigger and Bulk requests on our Force.com Apex Code Developer's Guide.
    5. Be sure you're following the key coding principals for Apex Code in our Developer's Guide.
    Important: Salesforce cannot disable the Governors Limit or raise it. Following the best practices above should ensure that you don't hit this limit in the future.

    Hope it may help you

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos