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
happy testerhappy tester 

System.LimitException: Too many SOQL queries: 101

We have triggers running to update Contact when Campaign Member Status is changed for different types of Campaigns. Each trigger has filtering, that means only those Campaign Members fall in a particular campaign will update Contact.  We have another new campaign and just developed a simple trigger to update Contact.  The trigger itself is running fine but when we deployed to production, another two test class has error "System.LimitException: Too many SOQL queries: 101".  One is related to Campaign while the other is related to Contact.  May I know why?

KaranrajKaranraj

It is the salesforce standard limit, check this link for salesforce Governors limits

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

 

Check this link for Apex code best practices

http://wiki.developerforce.com/page/Apex_Code_Best_Practices

prady-cmprady-cm

You could get this error because you might not have bulkified your triggers.

Check if you are trying to use a SOQL query inside a for loop.

if your loop runs 100 times then soql query gets excuted 100 times and would hit the governor limits.