Salesforce Certified Platform Developer II — Question 12

A developer is asked to update data in an org based on new business rules. The new rules state that Accounts with the type set to 'Customer' should have a status of 'Active', and Accounts with the type set to 'Prospect' should have a status of 'Pending'. No other changes to data should be made.
Which code block will accurately meet the business requirements?

Answer options

Correct answer: A

Explanation

Option A correctly implements the business rules by using a map to associate Account types with their statuses and updates only those accounts that match the criteria. Option B is incorrect because it filters accounts based on their current status rather than type. Option C fails to update all accounts appropriately as it does not handle cases where the Type is neither 'Customer' nor 'Prospect'. Option D sets the status for all accounts indiscriminately, which does not adhere to the specified business rules.