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
- A. Make an outbound web services call to the SOAP API.
- B. Hardcode the ID as a constant in an Apex class.
- C. Use the getRecordTypeInfosByName() method in the DescribeSObjectResult class.
- D. Execute a SOQL query on the RecordType object.
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.