public with sharing class Util {
private static map<String, Id> mapRecordTypes = new map<String, Id>();
public static Id getRecordTypeId(String rtObject, String rtName) {
try {
String rtKey = rtObject + '-' + rtName;
if (!mapRecordTypes.containsKey(rtKey)) {
System.debug('\n ### Queries: ' + Limits.getQueries() + '/' + Limits.getLimitQueries());
Id rid = [Select r.Id From RecordType r where r.SobjectType = : rtObject and (r.Name = : rtName OR r.DeveloperName = : rtName) and r.IsActive = true].Id;
system.debug('\n ### Adding RecordType Id ' + rid + ' for Sobject ' + rtObject + ' RecordType ' + rtName);
mapRecordTypes.put(rtKey, rid);
}
return mapRecordTypes.get(rtKey);
} catch (Exception ex) {
return null;
}
}
}
Regards,
Sagar Kavati,
Salesforce developer,
Cloud Credence.
No comments:
Post a Comment