You need to sign in to do that
Don't have an account?
SAI CHARAN MADUGULA
For me getting error like this System.LimitException: Apex CPU time limit exceeded
Hello All,
Can Anbody tell what is the issue please.
I am getting the like this Error:Apex trigger OCRtrigger caused an unexpected exception, contact your administrator: OCRtrigger: System.LimitException: Apex CPU time limit exceeded. I checked the debug logs it is shows the result like this.
Debug logs:
Class.AccountTriggerHandler.calculateDistance: line 572, column 1
Trigger.AccountTrigger: line 32, column 1 12:08:31.765 (43104659042)|FATAL_ERROR|System.LimitException: Apex CPU time limit exceeded
AccountTriggerHandler
public void calculateDistance(List<Account> TriggerNew,Map<Id,Account> TriggerOldMap,boolean isInsert,boolean isUpdate){
Set<Id> accIdSet = new Set<Id>();
for(Account acc : TriggerNew){
if(isInsert){
if(acc.OCR_Pharmacy_Name__c !=null && (acc.BillingStreet!=null || acc.BillingPostalCode!=null || acc.BillingCity!=null || acc.BillingSt ate!=null || acc.BillingCountry!=null)){
line 572, column 1 accIdSet.add(acc.Id);
}
}
AccountTrigger:
if(Trigger.isAfter)
{
//if(Trigger.new.size()<80){
if(Trigger.isInsert){
newHandler.calculateDistance(Trigger.new,null,true,false);
}
if(Trigger.isUpdate){
line 32, column 1 newHandler.calculateDistance(Trigger.new,Trigger.oldMap,false,true);
// new handler here 9/7/2016 contact owner trigger
UpdateContactHandler updateContactHandler = new UpdateContactHandler();
updateContactHandler.changeContactOwner(Trigger.oldMap, Trigger.newMap);
}
//}
}
Can Anbody tell what is the issue please.
I am getting the like this Error:Apex trigger OCRtrigger caused an unexpected exception, contact your administrator: OCRtrigger: System.LimitException: Apex CPU time limit exceeded. I checked the debug logs it is shows the result like this.
Debug logs:
Class.AccountTriggerHandler.calculateDistance: line 572, column 1
Trigger.AccountTrigger: line 32, column 1 12:08:31.765 (43104659042)|FATAL_ERROR|System.LimitException: Apex CPU time limit exceeded
AccountTriggerHandler
public void calculateDistance(List<Account> TriggerNew,Map<Id,Account> TriggerOldMap,boolean isInsert,boolean isUpdate){
Set<Id> accIdSet = new Set<Id>();
for(Account acc : TriggerNew){
if(isInsert){
if(acc.OCR_Pharmacy_Name__c !=null && (acc.BillingStreet!=null || acc.BillingPostalCode!=null || acc.BillingCity!=null || acc.BillingSt ate!=null || acc.BillingCountry!=null)){
line 572, column 1 accIdSet.add(acc.Id);
}
}
AccountTrigger:
if(Trigger.isAfter)
{
//if(Trigger.new.size()<80){
if(Trigger.isInsert){
newHandler.calculateDistance(Trigger.new,null,true,false);
}
if(Trigger.isUpdate){
line 32, column 1 newHandler.calculateDistance(Trigger.new,Trigger.oldMap,false,true);
// new handler here 9/7/2016 contact owner trigger
UpdateContactHandler updateContactHandler = new UpdateContactHandler();
updateContactHandler.changeContactOwner(Trigger.oldMap, Trigger.newMap);
}
//}
}
Not sure about your code but below are some posts for similar discussion which may help you to find a solution.
I hope in Trigger.Publication trigger you are using a loop inside the for loop.
The Maximum CPU time on the Salesforce servers - 10,000 milliseconds (Synchronous limit) 60,000 milliseconds(Asynchronous limit).
Please check below post to resolved this issue
http://salesforce.stackexchange.com/questions/22223/how-to-code-more-efficient-to-avoid-apex-cpu-time-limit-exceeded
http://salesforce.stackexchange.com/questions/47035/errorsystem-limitexception-apex-cpu-time-limit-exceeded
Hope this helps you!
Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
Thanks and Regards
Sandhya