Activity Forums Salesforce® Discussions In Batch class execute method default limit is 200.How can i Change this in salesforce?

  • Saurabh

    Member
    April 17, 2017 at 12:25 pm

    Hi Suraj

    You can use the Database.executeBatch(sObject className, Integer scopeSize) method to set the new  batch size.

    But you need to be sure that the scopeSize should less than 200.

    Database.executeBatch(sObject className, 50 ) would set the batch size to 50 instead of 200

    Hoping this may help you

  • shariq

    Member
    September 19, 2018 at 12:08 pm

    Hi,

    Database.executeBatch(sObject className, Integer scopeSize) is used to execute a batch.

    The Database.executeBatch method takes two parameters:An instance of a class that implements the Database.Batchable interface.
    An optional parameter scope. This parameter specifies the number of records to pass into the execute method. Use this parameter when you have many operations for each record being passed in and are running into governor limits. By limiting the number of records, you are limiting the operations per transaction. This value must be greater than zero. If the start method of the batch class returns a QueryLocator, the optional scope parameter of Database.executeBatch can have a maximum value of 2,000. If set to a higher value, Salesforce chunks the records returned by the QueryLocator into smaller batches of up to 2,000 records. If the start method of the batch class returns an iterable, the scope parameter value has no upper limit. However, if you use a high number, you can run into other limits.

    Thanks

     

  • Avnish Yadav

    Member
    September 19, 2018 at 12:26 pm

    Hello,

    Just pass the size argument in the executeBatch() method.

    Ex- Database.executeBatch(new BatchClassName, size )

    Thanks.

  • Parul

    Member
    September 19, 2018 at 1:07 pm

    Hi

    Adding some point:

    You can

    Database.executeBatch with the instance:

    batchExample be = new batchExample();
    database.executeBatch(new BatchClassName, size);

    With this limit we can set the limit of Batch inside Execute().

     

    Thanks

Log In to reply.

Popular Salesforce Blogs