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 :

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_recordtype.htm

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

https://trailhead.salesforce.com/content/learn/projects/customize-a-salesforce-object/create-record-types

Related Post

Leave a Reply

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