Error: System.LimitException: Too many SOQL queries: 101
“System.LimitException: Too many SOQL queries: 101” errors occur when you exceed SOQL queries governor limit. Actuval limit is “you can run up to a total 100 SOQL queries in a single call or context”.
Ho to resolve this “Error: System.LimitException: Too many SOQL queries: 101”
- Change your code by fallowing apex code best practices 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.
Apex runs on a multi-tenant platform, the apex run time engine strictly enforces limits to ensure code does not monopolize shared resources.
- Avoid SOQL queries in for loops.
- Fallow Apex code key principals while writing Triggers and bulk requests.
Reference for Apex code best practices: https://developer.salesforce.com/page/Apex_Code_Best_Practices