How
to get the Recordtype Id using Dynamic Apex
Normally to get the
RecordtypeId for any sObject we use SOQL and it will count against your limit.
So below method will bypass the need of SOQL Query.
Map<String,
Schema.SObjectType> m =
Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get('API_Name_Of_SObject')
;
Schema.DescribeSObjectResult
cfrSchema = s.getDescribe() ;
Map<String,Schema.RecordTypeInfo>
RecordTypeInfo = cfrSchema.getRecordTypeInfosByName();
Id rtId =
RecordTypeInfo.get('Record Type Name').getRecordTypeId();
No comments:
Post a Comment