I have the following apex file to update about 600 opportunity records that have status1 as Active and status2 as Inactive. status2 is a formula, status1 is a text field.
Running this via Execute Anonymous gives this error:
system.LimitException: Apex CPU time limit exceeded
public void updateStatus() {
List<Opportunity> records = [
SELECT Id FROM Opportunity WHERE status1__c = 'Active'
AND status2__c = 'Inactive'
];
for (Opportunity record : records)
{
record.status1__c = 'Inactive';
}
update records;
}
I played with it, the query part runs ok and shows the 600 rows selected in the logs. I think the update part is giving the timeout error. Not sure why. 600 rows shouldn't be too many. Or is it too many rows to update?