function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Default record type

In the visual force controller,  I want to get to the default record type of contact object that user can create.


Any idea how can I query that. 


User profile lists the default recordtypes for all the standard and custom objects. So I guess from userprofile this information would be available. But I am not able to figure it out. Any help?

Edwin VijayEdwin Vijay

If you need the exact information about databases..(User object in your case)


Go to Setup--> Develop --> API -- and click on Generate Enterprise WSDL


This WSDL will show you all available objects.. with all available fields...


Check for USER obj in this WSDL and see if there is any relationship which satisfies ur req...


I guess this will help you


I couldn't find a way to do this directly in the API documentation, so I don't think you can determine this value without using an indirect method. However, you could create a record using the user, then query that record back to determine the record type that was set (it will automatically default to the value for the user's object record type default). Note that using this rather excessively would fill up the recycle bin and possibly cause it tolose records before the normal 30 day limit.


Account a = new Account(Name='test');

insert a;

a = [select id,recordtypeid from account where id =];

// a.recordtypeid now has the user's preferred record type.


I am doing it this way now


Schema.DescribeSObjectResult oSObjectResult = Contact.SObjectType.getDescribe();


List<Schema.RecordTypeInfo> oRecTypeInfos = oSObjectResult.getRecordTypeInfos();


Schema.RecordTypeInfo has a method isDefaultRecordTypeMapping() that indicates if this is the default record type

for that user.