Exam CRT-450 Topic 4 Question 237 Discussion
Actual exam question for Salesforce's CRT-450 exam
Question #: 237
Topic #: 4
Question #: 237
Topic #: 4
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? ns
How can the developer find the current user's default record type? ns
Suggested Answer: B Vote an answer
To find the current user's default record type for a given object, such as Opportunity, the developer can use the Opportunity.SObjectType.getDescribe().getRecordTypeInfos() method to get a list of RecordTypeInfo objects that represent the record types available to the current user1. Then, the developer can iterate through the list and check the isDefaultRecordTypeMapping() method on each RecordTypeInfo object to determine which one is the default record type for the current user2. The default record type is the one that is automatically assigned to new records created by the user, unless the user selects a different record type3.
The developer cannot use the other options to find the current user's default record type. Option A is incorrect because there is no such method as profile.Opportunity.getDefaultRecordType(). Option C is incorrect because there is no such class as Schema.userInfo. Option D is incorrect because it does not find the default record type before inserting the record, but rather after creating the record, which may not be the same as the default record type. References:
* RecordTypeInfo Class | Apex Reference Guide | Salesforce Developers
* Get Default Record Type Id & Name in Apex - Salesforce Stack Exchange
* Set Record Type Preferences - Salesforce Help
The developer cannot use the other options to find the current user's default record type. Option A is incorrect because there is no such method as profile.Opportunity.getDefaultRecordType(). Option C is incorrect because there is no such class as Schema.userInfo. Option D is incorrect because it does not find the default record type before inserting the record, but rather after creating the record, which may not be the same as the default record type. References:
* RecordTypeInfo Class | Apex Reference Guide | Salesforce Developers
* Get Default Record Type Id & Name in Apex - Salesforce Stack Exchange
* Set Record Type Preferences - Salesforce Help
by Harry at Mar 14, 2024, 10:01 AM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).