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.

  • I'm wondering about your need to know the default record type. When apex code executes as a user, the sobject record that will be created will have the record type which is default for the users profile for that sObject. Oct 15, 2012 at 6:35
  • That is correct! I over thought the problem! Thanks! Oct 15, 2012 at 7:02
  • Happens all the time ;) Oct 15, 2012 at 7:07

1 Answer 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;
  • As techtrekker said, that was unnecessary. But on the other hand, the snippet worked as expected! Thanks! Oct 15, 2012 at 7:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .