System.LimitException: Too many SOQL queries: 101
This exception occurs when you exceed the SOQL queries governor limit. You can run up to a total of 100 SOQL queries in a single call or context.
Sample Business Use Cases
- If you finalize a cart that has 50 to 60 ramp lines, the cart stops responding.
- Each product added to the cart has a constraint rule. When you add 90 line items to the cart, constraint rules fail to work.
Best Practices
- Change the code by following the Apex Code best practices so that the number of SOQL queries triggered is less than 100.
- Change the context; use the @future annotation, which runs the code asynchronously.
- Ensure that you do not have a recursive loop calling a SOQL.
- Follow Apex Code key principals while writing triggers and bulk requests.
- Do not perform any DML or CRUD operation inside a For loop.
In CPQ
- Enable the Run Misc Finalization Task in Async Mode setting in Config System Properties (Developer Setting).