To refer record type in SOQL use the below code:

list<lead>leadlist=[SELECT id,Name,email,RecordType.DeveloperName FROM lead];

To refer record type in Apex without SOQL :

If we want to refer the recordtype on LEAD object with the name recordtype1 ,use the below code

Id id_of_record_type = Schema.SObjectType.lead.getRecordTypeInfosByName().get('recordtype1').getRecordTypeId();

You can also refer the salesforce documentation for recordtype :

You can also solve the trailhead task to understand the concept of recordtype to create record types in salesforce:

Related Post

Leave a Reply

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