Wednesday, April 19, 2017

Get sObject type from the recordId

Map<String,String> keys = new Map<String,String>();
        Map<String,Schema.SobjectType> describe = Schema.getGlobalDescribe();
        for(String s:describe.keyset())
            keys.put(describe.get(s).getDescribe().getKeyPrefix(),s);
     
     
        system.debug('@@@@'+keys.get(String.valueOf(recordId).substring(0,3)));

No comments:

Post a Comment