Get Record Type ID Using Object Name

We can get the Object Record Type Id values in multiple ways like using SOQL, getDescribSObject and below are some examples:

Example 1:

//Replace Object Name (API Name) and Record Type Name (Record Type API)
private static Id businessAccountRecTypeId = null;
private static Id getEventRecodTypeId() {
if (businessAccountRecTypeId == null) {
businessAccountRecTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(‘Business_Account’).getRecordTypeId(); //Business_Account RecordType API value from Account Object
return businessAccountRecTypeId;

Example 2:
//Replace Object Name (API Name) and Record Type Name (Not Record Type API)

Id businessAccountRecTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get(‘Business Account’).getRecordTypeId();

Example 3:
This way to get a recordTypeId using SOQL query in Apex
[Select id from RecordType where sObjectType = ‘Account’ and developerName =’Business_Account’].id

Important Note:
Salesforce Developer Tips: How to get a RecordType Id by Name without SOQL, use always as per example 1 without using SOQL Query to retrieve Object Record Type ID.

Useful Links:



Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

Your email address will not be published. Required fields are marked *