Scenario: You are working for a company that manages a large number of customer records. The company wants to update the email addresses of all customers based on certain criteria. However, due to the large volume of customer data, you need to implement a batch process to update the records efficiently.

Assignment:

  1. Create a custom object called “Customer__c” with the following fields:
    • Name (Text)
    • Email__c (Email)
    • IsActive__c (Checkbox)
  2. Write a batch Apex class called “EmailUpdateBatch” that implements the Database.Batchable<sObject> interface.
  3. Implement the start, execute, and finish methods in the “EmailUpdateBatch” class:
    • In the start method, query for all active customers whose email addresses need to be updated.
    • In the execute method, iterate over the queried customer records, and update their email addresses.
    • In the finish method, provide a log or summary of the batch execution.
  4. Execute the batch process to update the email addresses of the customers.
  5. Validate that the email addresses have been successfully updated for the appropriate customer records.

Extra Credit (Optional):

  • Include batch monitoring and reporting functionality to track the progress of the batch execution.

This assignment will give you hands-on experience in creating and executing batch Apex classes to efficiently process a large number of records. It will also test your ability to write test classes to ensure the functionality of your code.