//Generate a map of tokens for the sObjects in your organization
Map gd = Schema.getGlobalDescribe();
//Retrieve the describe result for the desired object
DescribeSObjectResult result = gd.get('Account').getDescribe();
//Generate a map of tokens for all the Record Types for the desired object
Map recordTypeInfo = result.getRecordTypeInfosByName();
system.debug('RECORD TYPES:' + recordTypeInfo);
//Retrieve the record type id by name
String recordTypeId = recordTypeInfo.get('RECORDTYPE_NAME').getRecordTypeId();
OR
//Retrieve the record type id by name
String recordTypeId = Schema.getGlobalDescribe().get('Account').getDescribe().getRecordTypeInfosByName().get('RECORDTYPE_NAME').getRecordTypeId();
System.debug('@@@-----'+recordTypeId);
No comments:
Post a Comment