In my previous post, I have explained to you how to use the Salesforce Object Key Prefix to save your time. If you haven’t seen that yet
In this post, I will explain how to get the key prefix for a custom object.
Every custom object in Salesforce has its unique key prefix, using which they are uniquely identified. We will be getting the key prefix for one of the custom objects in our SF organization.
Let’s say we have a custom object “Invoices__c”, and we want the Key Prefix of this object. By using apex we can get the prefix of that object in the developer console.
String keyPrefix = Invoices__c.SObjectType.getDescribe().getKeyPrefix(); System.Debug('Key Prefix: ' + keyPrefix);
Note: You can get the key prefix for any of your custom