Sometimes in apex we required RecordType Id of an object by its Name. So, here is an example how we can find RecordType Id by Name.
In below example BankAccount__c
is the custom object and “Savings Account” is one of the RecordType Name of BankAccount__c
object. Now without SOQL I’ve to find “Savings Account” RecordType Id.
String recordTypeName = 'Savings Account'; Schema.SObjectType.BankAccount__c.getRecordTypeInfosByName().get(recordTypeName).getRecordTypeId();