Tuesday, December 6, 2016

How to get RecordTypeId without SOQL | Get RecordTypeId by Describe Call.


Using SOQL like below :

Id contRecordTypeId = [Select id from RecordType where sObjectType = 'Contact' and 
developerName ='NameOfRecordType' ].id ;


Using Describe to get record Type Id without SOQL :

Id contRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('NameOfRecordType').getRecordTypeId();


No comments:

Post a Comment