Exam Certified Platform Developer II All QuestionsBrowse all questions from this exam
Question 214

A company wants to run different logic based on an Opportunity’s record type.

Which code segment handles this request and follows best practices?

    Correct Answer: C

    The best practice for handling different logic based on an Opportunity’s record type is to use the Schema class to get the record type IDs by their developer names. This approach avoids hardcoding IDs and ensures that the correct IDs are retrieved in a more efficient manner. By using Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('DeveloperName').getRecordTypeId(), it directly accesses the required record type IDs based on the developer names, making the code clean and maintainable. Therefore, option C correctly follows these best practices.

Discussion
Udayudyvk1818Option: C

to simply use getRecordTypeInfosByDeveloperName https://salesforce.stackexchange.com/questions/11968/what-would-be-the-best-approach-to-get-the-recordtype-id

dasabhisek404

Why not Option A?

AppleDashOption: C

Should be C.