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
Ankit Chauhan 10Ankit Chauhan 10 

Best approach to perform a batch operation within Salesforce on Standard Objects like Account, Lead

Hi All,
I'm quite new to Salesforce and I have been struglling to get the best approach to do batch operations on Salesforce standard objects like Account, Lead etc. I'm planning to create a batch job which contains batch operations on standard salesforce objects. Is there any existing way I can achieve the same within salesforce. I don't want to implement a fancy UI to perform this I'm planning to use the existing List View and add a custom button on it to perform the batch operations.

How my batch operations will work-
1. User selects a bunch of records (from Salesfroce standard objects)
2. System creates a new batch job from the user's selected records.
3. User click on Custom button (provided by me for Batch Processing)
4. Records gets updated and the job status (Pass/Fail) gets saved against the JobID#.
5. Will update the salesforce standard objects as per the batch operations.
Preya VaishnaviPreya Vaishnavi
Hi Ankit,

Your approach looks good.Some pointers

1.What will you pass while executing the batch.Is it a list or are you going to query in query locator of the batch.
2.What will the batch do(insert ,update,etc)
3.Do you plan to implement same batch job for all the salesforce objects with the same approach? (what are the objects involved here)
Ankit Chauhan 10Ankit Chauhan 10
Hi Preya,
Thanks for reqplying. To answer your question:

1.What will you pass while executing the batch.Is it a list or are you going to query in query locator of the batch.
   I will pass the record fields like email, phone.

2.What will the batch do(insert ,update,etc)
   I will update the records.

3.Do you plan to implement same batch job for all the salesforce objects with the same approach? (what are the objects involved here)
   Yes, currenlty I'm planning to use the same approach for all the SO. Unless I have any better approach.
Preya VaishnaviPreya Vaishnavi
In a batch ,you could pass a list of selected records or you should be able to query using query locator in the batch.Reduce the batch size if you hit cpu limit error (if there are many triggers or workflows on an object and the size of the batch is a greater number).
Ankit Chauhan 10Ankit Chauhan 10
I'm planning to pass the list of Ids of selected records.
So I'm still looking for existing better/ correct approach within Salesforce which I can leverage for the Batch Jobs.