You need to sign in to do that
Don't have an account?
Swati Atrey 8
Apex trigger on Lead, causing "Apex CPU time limit exceeded"
Hi Team,
I am getting error on bulk Lead import, "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:CheckLeadDNCR: System.LimitException: Apex CPU time limit exceeded:--".
I checked trigger CheckLeadDNCR, it is not inserting/updating any data its a normal if else and very short trigger. Then why this error is coming on this trigger
I am getting error on bulk Lead import, "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:CheckLeadDNCR: System.LimitException: Apex CPU time limit exceeded:--".
I checked trigger CheckLeadDNCR, it is not inserting/updating any data its a normal if else and very short trigger. Then why this error is coming on this trigger
Code is very simple and curLead.ASG_Contact__c is NULL (not in CSV), so effectively this code do not process anything, still giving error
trigger CheckLeadDNCR on Lead (after insert, before update) {
for(Lead curLead:trigger.new) {
if(system.isFuture()) return;
if (system.trigger.isInsert) {
if (curLead.ASG_Contact__c != null) {
DNCRConnectorWebserviceCallout.checkDNCR(curLead.Phone,curLead.ASG_Work_Phone_Number__c,curLead.MobilePhone,curLead.ASG_Home_Phone__c,curLead.Id,'Lead',1);
}
} else if (system.trigger.IsUpdate) {
if(system.isFuture()) return;
Lead prevLead = trigger.oldMap.get(curLead.Id);
//if (curLead.ASG_Contact__c != null &&
// (curLead.Phone != prevLead.Phone || curLead.MobilePhone != prevLead.MobilePhone || curLead.ASG_Work_Phone_Number__c != prevLead.ASG_Work_Phone_Number__c ||
// curLead.ASG_Contact__c != prevLead.ASG_Contact__c)) {
if (curLead.ASG_Contact__c != null){
DNCRConnectorWebserviceCallout.checkDNCR(curLead.Phone,curLead.ASG_Work_Phone_Number__c,curLead.MobilePhone,curLead.ASG_Home_Phone__c,curLead.Id,'Lead',1);
}
}
}
}