Find Object Key Prefix using Name in Salesforce Apex

Find Object Key Prefix using Name in Salesforce Apex

To find Object Key Prefix using Name in Salesforce Apex, we can use getKeyPrefix() method from DescribeSObjectResult class.

Sample Code: 

DescribeSObjectResult sobjectRes = 
	PendingServiceRouting.sObjectType.getDescribe();
System.debug(
	'Key prefix is ' + 
	sobjectRes.getKeyPrefix()
);

Output:

Leave a Reply