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
Hit23Hit23 

Apex Code Deployment issue

Hello,

 

I have 3 triggers on different object as name following: UpdateCount, UpdateDPCfromAccount and UpdateAccountData.

I have also test class, which gives 100% code coverage to all three triggers.

 

Now when i deploy this 3 triggers & Test class in production, it is throwing me an errors on other classes/triggers line code which are already in production.

 

Error is: Too many SOQL queries: 101

 

How my Triggers invoked to other classes/triggers in production? If it is the case then what is the best solution?

I already review my code again and tried to reduce the query..but still same errors.

 

Please suggest me the best way.

 

Thanks,

Hit

 

Cory CowgillCory Cowgill

This is usually caused by bad trigger code and/or bad test cases.

 

1. Test cases should not rely on existing data in an org. Make sure that your Unit Tests are creating scratch test data for each test. Make sure that your not relying on existing test data with something like List<Account> testAccount = [Select Id from Account];

 

2. Make sure you don't have SOQL inside For Loops.

 

3. If your getting a recursive trigger firing causing this error, use a static variable flag to only execute the trigger once. Here is the documentaiton on this pattern / best practice :http://www.salesforce.com/docs/developer/cookbook/Content/apex_controlling_recursive_triggers.htm