Posts

Showing posts with the label Get sObject prefix

Get sObject prefix

  Pass object name in method parameter. *** public static void getPrefix(String objName){         Schema.sObjectType sObjType = Schema.getGlobalDescribe().get(objName);         String prefixValue = (sObjType.getDescribe().getKeyPrefix());         System.debug('prefixValue##' + prefixValue);     } *** OR you can get prefix value from here *** Schema.DescribeSObjectResult r = Account .sObjectType.getDescribe(); String keyPrefix = r.getKeyPrefix(); System.debug('keyPrefix##' + keyPrefix); *** Replace Account object from your object name.