A company wants to run different logic based on an Opportunity’s record type.
Which code segment handles this request and follows best practices?
A company wants to run different logic based on an Opportunity’s record type.
Which code segment handles this request and follows best practices?
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.
to simply use getRecordTypeInfosByDeveloperName https://salesforce.stackexchange.com/questions/11968/what-would-be-the-best-approach-to-get-the-recordtype-id
Why not Option A?
Should be C.