• #27027
    Salesforce | Ankit Ankit #951

    What is the role of Scope parameter in Salesforce Batch Apex

    What is the role of Scope parameter in Salesforce Batch Apex


     Rajan #947

    Hi ankit

    Scope 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.

    Hope this help!

    Salesforce | Adarsh Adarsh #958

    Hi Ankit,

    Batch Apex
    A Batch class allows you to define a single job that can be broken up into manageable chunks that will be processed separately.

    When to use Batch Apex
    One example is if you need to make a field update to every Account in your organization. If you have 10,001 Account records in your org, this is impossible without some way of breaking it up. So in the start() method, you define the query you’re going to use in this batch context: ‘select Id from Account’. Then the execute() method runs, but only receives a relatively short list of records (default 200). Within the execute(), everything runs in its own transactional context, which means almost all of the governor limits only apply to that block. Thus each time execute() is run, you are allowed 150 queries and 50,000 DML rows and so on. When that execute() is complete, a new one is instantiated with the next group of 200 Accounts, with a brand new set of governor limits. Finally the finish() method wraps up any loose ends as necessary, like sending a status email.

    Sample Batch Apex
    1) Start method is automatically called at the beginning of the apex job. This method will collect record or objects on which the operation should be performed. These record are divided into subtasks & passes those to execute method.

    2) Execute Method performs operation which we want to perform on the records fetched from start method.

    3) Finish method executes after all batches are processed. Use this method to send confirmation email notifications.

    Salesforce | Archit Archit #957

    Hello Ankit,

    In short we can say Scope will return the List of record based on your start method in batch class.


Viewing 4 posts - 1 through 4 (of 4 total)

Please to reply to this topic.

Popular Salesforce Blogs


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2020 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?