+ Start a Discussion
Derek Patrick DayaDerek Patrick Daya 

Deactivating a Trigger issue

I have a trigger that I previously deployed on my production. It has 100% code coverage and did not have any problem with any of the triggers.

Recently with the updates done by the Third Party App, started experiencing error with our custom send email button on a VF page. It produces SOQL Limit error. Upon checking debug logs, we notice that my trigger is the one causing it. Now I am trying to deactivate it but without any success.

1. Deactivated trigger on Sandbox and deploy it to prod. we received Apex Heap Size error upon deploying.
2. Tried to uncomment out all the codes in test class and trigger, I still received the same error.
3. Used Force.com IDE, downloaded the trigger and change it there to inactive then deployed to server, same error is received. Heap Size error on 3 test classes on the production.

Did anyone experience same issues before? Can any shed some other ways to deactivate that trigger?
Shashikant SharmaShashikant Sharma
Coul you share the complete deployment error message ?
Derek Patrick DayaDerek Patrick Daya
SendingMailTriggerTestClass.UnitTestMethod(), Details: System.LimitException: Apex heap size too large: 62647825 External entry point (AVTRRT)

DerekSendUpdatesToApplicantsTestClass.DerekSendUpdatesToApplicants(), Details: System.LimitException: Apex heap size too large: 62615875 External entry point (AVTRRT)

same error on change sets and Force.com IDE

Salesforce has Governor Limits for the heap size, which is 6MB. You can update/improve the code and see whether that will help.

You can also take a look at the following links:
kanchi chandrakanchi chandra
you can able to change the triggers in production. In before move to production to create the customsettings. this is dynamically change the varible values so simiply checking checkbox and write some coditions, so deactivate the triggers
Derek Patrick DayaDerek Patrick Daya
Hi Kanchi, sorry but I am not familliar with custom settings as I am new to APEX. Yuchen, I was looking to put a logic on my test class that will prevent hitting APEX Heap Size. Can you suggest a way to go about this?

Test Class:

private class DerekApplicantsWithActivityTestClass{
    static testMethod void DerekCountApplicantsWithActivity() {
      Date CurrentDate = Date.Newinstance(2014,11,12);
      AVTRRT__Job__c a = new AVTRRT__Job__c();
      a.AVTRRT__Job_Title__c = 'Sys Ad';
      insert a;

      Contact c = new Contact();
      c.FirstName = 'Derek';
      c.LastName = 'Daya';
      c.Email = 'derekpatrickdaya@yahoo.com';
      insert c;
      AVTRRT__Job_Applicant__c b = new AVTRRT__Job_Applicant__c();
      b.AVTRRT__Job__c = a.id;
      b.AVTRRT__Contact_Candidate__c = c.id;
      b.Last_Activity_Date__c = CurrentDate;
        insert b;


trigger DerekCountApplicantsWithActivity on AVTRRT__Job__c (before update) {
for (AggregateResult ar : [
     Select Count(Id) numRecs, AVTRRT__Job__c jobId
     From AVTRRT__Job_Applicant__c
     Where Last_Activity_Date__c != null and AVTRRT__Job__c In :Trigger.New
     Group By AVTRRT__Job__c
]) {
    Id jobId = (Id) ar.get('jobId');
    AVTRRT__Job__c job = Trigger.newMap.get(jobId);
    job.Number_of_Applicants_with_Activities__c = (Decimal) ar.get('numRecs');
Shashikant SharmaShashikant Sharma
First make your test class Org data independent by modifying  seeAllData=true to


It will make sure that your test class is not processing any data from your org. 

Derek Patrick DayaDerek Patrick Daya
When I set seeAllData=false it gives me an error that say trying to reference a null object.