0

I have written trigger in salesforce code,it is already bulkified,But i am getting cpu limit exceeded error,while updating 200 records using Workbench

Trigger code:

trigger AccountTrigger on Account (before Update,after insert, after update) {
if(Trigger.IsUpdate){ 

            List<Summary__c> sumUpdatelst = [SELECT Id, Name, Account__c FROM Summary__c WHERE Account__c = : trigger.new];

            if(sumUpdatelst.isEmpty()){

                List<Summary__c> sumlst = new List<Summary__c>();

                for(Account acq : trigger.new){ 
                    sumlst.add(New Summary__c(Name = acq.Name, Account__c = acq.Id, Recordtype = acq.RecordType));
                }

                If(!sumlst.isEmpty()){
                    INSERT sumlst;
                } 
            } 
        }
    }

    If(Trigger.IsAfter){

        if(Trigger.IsInsert){

            List<Summary__c> sumlst = new List<Summary__c>();

            for(Account acq : trigger.new){

                sumlst.add(New Summary__c(Name = acq.Name, Account__c = acq.Id, Recordtype = acq.RecordType));
            }
            If(!sumlst.isEmpty()){
                INSERT sumlst;
            }
        }
    }
}

Error :

"Id","Success","Created","Error" "","false","false","CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:objectTrigger: System.LimitException: Apex CPU time limit exceeded:--" "","false","false","CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:objectTrigger: System.LimitException: Apex CPU time limit exceeded:--" "","false","false""","false","false","CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:AccountTrigger: System.LimitException: Apex CPU time limit exceeded:--" "","false","false","CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:objectTrigger: System.LimitException: Apex CPU time limit exceeded:-

-

3
  • Comments are not for extended discussion; this conversation has been moved to chat. – Adrian Larson Mar 14 '18 at 14:47
  • Is Summary__c object master-detail to Account object? Also is your processes update account in any way? – tugce Mar 14 '18 at 18:22
  • lookupRealtionship summary__c to Account object @tugce – SFDC developer Mar 15 '18 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.