Skip to content

Instantly share code, notes, and snippets.

@victorabraham
Created August 14, 2020 04:04
Show Gist options
  • Select an option

  • Save victorabraham/5c45fbf1de246e113941a8331d02e8a5 to your computer and use it in GitHub Desktop.

Select an option

Save victorabraham/5c45fbf1de246e113941a8331d02e8a5 to your computer and use it in GitHub Desktop.
public with sharing class RecordTypeUtil {
//Do not use this
public static Id getRecordTypeIdWithoutCache(String objectName, String recordtypeName) {
Map<String, Schema.SObjectType> sObjectTypeMap = Schema.getGlobalDescribe();
Schema.SObjectType sotype = sObjectTypeMap.get(objectName);
Map<String, Schema.RecordTypeInfo> recordTypeMap = sotype.getDescribe().getRecordTypeInfosByName();
return recordTypeMap.get(recordTypeName).getRecordTypeId();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment