Find your content:

Search form

You are here

Find out the default record type of any Object in Apex


I've to find out the default record type of an Object so that I can use in Apex to insert/update records.

Found out that it is at the user level(user profile based). Is there any other way which I can use to find out the default record type of an object.

It makes sense why it is at the user level, but just out of curiosity I'm looking for another option to get irrespective of the user profile.

Attribution to: Vignesh Damodharan

Possible Suggestion/Solution #1

You can use apex describe to get the record type details of any object. This information will be correct for the running user.

Schema.DescribeSObjectResult dsr = Account.SObjectType.getDescribe();
Schema.RecordTypeInfo defaultRecordType;
for(Schema.RecordTypeInfo rti : dsr.getRecordTypeInfos()) {
    if(rti.isDefaultRecordTypeMapping()) {
        defaultRecordType = rti;

Attribution to: Daniel Blackhall
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content