The use case is when a user goes Personal Setup > My Personal Information > Record Type selection and checks the box for the default to be selected automatically when a record is created.

In this case, the Record Type Id does not come through on the URL. But on the page, I need to know the Record Type to do some field pre-population.

How do I get this default Record Type Id?

  • 1
    Your question is unclear. What do you mean by disable the record type selector on the left nav? Where, in setup, on a VF page, on a record? Are you talking about the sidebar, what left nav?
    – greenstork
    May 1, 2013 at 21:22
  • clarified the post for you May 1, 2013 at 21:35
  • 1
    More clarification needed, how are you trying to do field pre-population, with JS in a button, with a VF page? The record type id does not come through on which record URL, the new button?
    – greenstork
    May 1, 2013 at 21:51
  • Record Type is normally a function of the Profile assigned to a User for a particular Object. In most cases, a different VF page will be displayed that's dependant on the User's Profile.
    – crmprogdev
    May 1, 2013 at 21:55

2 Answers 2


The closest I can get is the default record type for the current user:

//find all Opportunity record types
List<Schema.RecordTypeInfo> infos = Schema.SObjectType.Opportunity.RecordTypeInfos;
Id defaultRecordTypeId;

//check each one
for (Schema.RecordTypeInfo info : infos) {
  if (info.DefaultRecordTypeMapping) {
    defaultRecordTypeId = info.RecordTypeId;

//here is the default Opportunity RecordType Id for the current user
  • 1
    Code is not valid. You might want to finalize it ...
    – Martin
    Sep 5, 2014 at 8:30
  • Code is not clear, what is rti?
    – flor
    Sep 30, 2016 at 5:52

Got it....

if (ApexPages.currentPage().getParameters().get('RecordType') == null) {
    Schema.DescribeSObjectResult describeOpp = Schema.SObjectType.Opportunity;    
    List<Schema.RecordTypeInfo> rtInfos = describeOpp.getRecordTypeInfos();
    for(Schema.RecordTypeInfo rtInfo : rtInfos) {
        if(rtInfo.isDefaultRecordTypeMapping()) {               
            ApexPages.currentPage().getParameters().put('RecordType', rtInfo.getRecordTypeId());
      String recordRT = ApexPages.currentPage().getParameters().get('RecordType');
  • Of course! I appreciate your helpfulness! May 2, 2013 at 1:13
  • The following solution does not work for me. I have user for which only one record type is available and this solution returns master record type, which is unavailable for him, leading to INSUFFICIENT PRIVILEGES error. The solution however is quite simple. You just need to switch rtInfo.isDefaultRecordTypeMapping() to rtInfo.isAvailable(). That worked for me.
    – Wookie88
    Dec 11, 2015 at 16:07

You must log in to answer this question.

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