Activity Forums Salesforce® Discussions What are the different methods of batch Apex class in Salesforce?

  • What are the different methods of batch Apex class in Salesforce?

    Posted by Marziya on January 23, 2020 at 1:59 pm

    What are the different methods of batch Apex class in Salesforce?

    • This discussion was modified 4 years, 11 months ago by  Marziya.
    Udit replied 4 years, 11 months ago 2 Members · 1 Reply
  • 1 Reply
  • Udit

    Member
    January 23, 2020 at 2:14 pm

    There are three methods in Batch Apex.

    1. Start: This method is called at the very beginning and it is used to collect the records through query or objects to be passed to the execute method.
      Syntax: global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {}
    2. Execute: We use this method to do required processing for every chunk of data.
      Syntax: global void execute(Database.BatchableContext BC, list<ListOfRecords>){}
    3.  Finish: This method is executed after all the batches are processed. We can use this method to send email confirmations or execute post processing operations.
      Syntax: global void finish(Database.BatchableContext BC){}

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos