+ Start a Discussion
Yogesh BiyaniYogesh Biyani 

Line: 22, Column: 1 System.LimitException: Apex CPU time limit exceeded

I am using the following code to update the states and see the error mentioned in the subject. As you can see there is no line 22; so why am I getting this error message? 
 
List<Contact> cts = new List<Contact>();

List<Contact> contacts=[SELECT Id, MailingState from Contact WHERE MailingState='---' LIMIT 1000];
for(Contact a: contacts){
    
    a.MailingState='';
    cts.add(a);
}

update cts;



 
AmitdAmitd
Hi Yogesh,

You are doing DML in line 10. Please check is there any trigger on Contact. This line number can belong to your trigger. Or even lets say you have used any helper class in trigger, this line number could be in that class as well.