Salesforce Platform Developer I (legacy) — Question 224

A Platform Developer needs to write an Apex method that will only perform an action if a record is assigned to a specific Record Type.
Which two options allow the developer to dynamically determine the ID of the required Record Type by its name? (Choose two.)

Answer options

Correct answer: C, D

Explanation

The correct answers, C and D, allow the developer to dynamically retrieve the Record Type ID based on its name. Option C utilizes the getRecordTypeInfosByName() method, which directly retrieves the Record Type's information, while option D involves a SOQL query on the RecordType object to obtain the ID. Options A and B are not suitable as they involve either external calls or hardcoding, which do not meet the requirement for dynamic determination.