Get key prefix of an object using Apex

By | December 31, 2014

Every record in Salesforce has an ID which is used to uniquely identify the record. Each ID value is globally unique. The first three digits represent the object type.

For example, the Account object uses the 001 prefix; the Note object uses the 002 prefix, Contact uses 003, Users 005, Opportunity 006 etc.

We can get these prefix values dynamically as well using Apex. To do this, use the below Apex code–

Key PrefixThis will print prefix of the Account object. The key prefixes for all the standard objects remain the same. You can use the above Apex code to get the key prefix of your custom objects. To do this just replace Account with the name of your custom object to obtain the key prefix of that custom object.

About Us
Greytrix as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce integration with Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support to business partners and end users.

Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star app listed on Salesforce AppExchange.

For more information, please contact us at salesforce@greytrix.com. We will be glad to assist you.

Related Posts