Play Games

Search This Blog

Tuesday, November 3, 2015

Get Record Type Id by Name in apex

Suppose I have created "Supplier" as record type in account object as shown in the image below.

Now to get id of this record type,use the code below
Id recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Supplier').getRecordTypeId();
system.debug('recordTypeIdrecordTypeId'+recordTypeId );

Output: recordTypeIdrecordType Id012280000009tHsAAI
Here 18 digit Id is displayed.