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
frankcsefrankcse 

Updating Accounts

Hi,
Please any one can help me for the following Query?
 
In one of My application i am updating SalesForce Accounts using update method of sforceservice class. And i am using arry of account object.
My Question is How many records i can hold in this array.... I mean i want to know the size of the array
At a time how many records i can update using update method?
Is there any limitation for the number of records to be updated at a time?
I want to update more than 3000 records at a time..
 
Please help me for this
 
Thanks
Regards
Franklin
SuperfellSuperfell
You can't pass more than 200 items at a time to update (or create, upsert). If you have more to do than that, you need to call update repeatedly doing 200 at a time.

I find a small accumulator object really handy for managing this, something like

class updateAccumulator {
   updateAccumulator(sf.SforceService s, int maxPerBatch) {
     this.svc = s;
    this.max = maxPerBatch;
    this.objects = new ArrayList(this.max);
  }
   private sf.SforceService svc;
   private int max;
   private ArrayList objects;
 
   void update(sf.SObject o) {
     objects.add(o);
    if (objects.count() >= max) flush();
   }

   void flush() {
      if (objects.count() == 0) return;
      sf.SaveResult [] sr = svc.update(objects.ToArray());
      foreach(sf.SaveResult res : sr)
          if(!sf.success) throw new Exception(sf.Error[0].StatusCode + " " + sf.Error[0].Message);
   }
     objects.clear();
}

sometimes this can make the batching easier, depending on how you need to handle errors.

   
frankcsefrankcse
Thank you Simon........
I am So happy now just now i have found that size is not more than 200
But u have given me solution to update more than that.
Thanks
Regards
Franklin