Certified Platform Developer II Exam QuestionsBrowse all questions from this exam

Certified Platform Developer II 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?

Show Answer
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

2 comments
Sign in to comment
AppleDashOption: C
May 30, 2023

Should be C.

Udayudyvk1818Option: C
Aug 5, 2023

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

dasabhisek404
Jul 6, 2024

Why not Option A?