A developer is creating a page that allows users to create multiple Opportunities. The developer is asked to verify the current user's default Opportunity record type, and set certain default values based on the record type before inserting the record.
How can the developer find the current user's default record type?
Correct Answer: D
This method allows the developer to retrieve all available record types and identify the default record type for the current user by checking theisDefaultRecordTypeMapping()attribute.
Example:
Schema.DescribeSObjectResult describeResult = Opportunity.sObjectType.getDescribe(); for (Schema.RecordTypeInfo recordType : describeResult.getRecordTypeInfos()) { if (recordType.isDefaultRecordTypeMapping()) { System.debug('Default Record Type: ' + recordType.getName());
}
}
Schema.RecordTypeInfo Methods