Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
String myIdPrefix = String.valueOf(someId).substring(0,3); //get just the prefix Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); for(Schema.SObjectType stype : gd.values()) { Schema.DescribeSObjectResult r = stype.getDescribe(); String prefix = r.getKeyPrefix(); System.debug('Prefix is ' + prefix); if(prefix!=null && prefix.equals(myIdPrefix)) { System.debug('Stop hammer time! ' + r.getName()); break; } }
Use below code :
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.