function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lodoss118lodoss118 

How do you mass update a record, without getting into governor limits?

I have a sales order object and want to update a field on all the records, but i keep getting errors about governor limits
can anyone give me a quick pseudo code on how to do it, thanks.
lodoss118lodoss118
hmm i am prtty sure that doesn;t update all the records i am talking about old records not new ones, i.e. i have 5000 sales orders i want update a field on all those records

what i did is create a list and selected all approved orders

salesList = new  List<SCRB_SalesOrder__c>([select id, name, approved__c, estDate__c, approvedDate__c from SCRB_SalesOrder__c where approved__c = true]);

if(salesList.size() > 0) {
      for(SCRB_SalesOrder__c s : salesList) {
               if(s != null) {
                    s.estDate__c= approvedDate__c.addDays(2);
               }
      }
    
     update salesList;
}

but i always get errors when trying to deploy to the live system, i.e.about governor limits