{"id":784,"date":"2014-12-31T09:22:47","date_gmt":"2014-12-31T09:22:47","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=784"},"modified":"2020-06-30T14:01:34","modified_gmt":"2020-06-30T14:01:34","slug":"get-key-prefix-of-an-object-using-apex","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/12\/31\/get-key-prefix-of-an-object-using-apex\/","title":{"rendered":"Get key prefix of an object using Apex"},"content":{"rendered":"<p>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.<\/p>\n<p>For example, the Account object uses the 001 prefix; the Note object uses the 002 prefix, Contact uses 003, Users 005, Opportunity 006 etc.<\/p>\n<p>We can get these prefix values dynamically as well using Apex. To do this, use the below Apex code\u2013<\/p>\n<p><a href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/12\/Key-Prefix.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-785\" src=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/12\/Key-Prefix.jpg\" alt=\"Key Prefix\" width=\"555\" height=\"91\"><\/a>This 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.<\/p>\n<p><span style=\"font-size: Medium;\"><strong>About Us<\/strong><\/span><br \/>\n<a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> 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.<\/p>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> has some unique solutions for Cloud CRM such as Salesforce integration with <a href=\"https:\/\/www.greytrix.com\/product\/sage-x3\/gumu-x3-salesforce-integration\">Sage Enterprise Management (Sage X3<\/a>), Sage Intacct, <a href=\"https:\/\/www.greytrix.com\/product\/sage-100-erp\/gumu-100-salesforce-integration\">Sage 100 <\/a>and <a href=\"https:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM <a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/data-migration-services\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/integrated-application-development\">Integrated App development<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/custom-development\">Custom App development<\/a> and <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/maintenance-support\">Technical Support<\/a> to business partners and end users.<\/p>\n<p>Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star app listed on <a href=\"https:\/\/appexchange.salesforce.com\/listingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<\/p>\n<p>For more information, please contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n<p><strong><span style=\"font-size: Medium;\">Related Posts<\/span><\/strong><\/p>\n<ul>\n<li><a title=\"Delete apex class or trigger in Salesforce Production Org\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/11\/29\/delete-apex-class-or-trigger-in-salesforce-production-org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Delete apex class or trigger in Salesforce Production Org<\/a><\/li>\n<li><a title=\"Quick way to find out the release of Salesforce Instance\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/11\/29\/quick-way-to-find-out-the-release-of-salesforce-instance\/\" target=\"_blank\" rel=\"noopener noreferrer\">Quick way to find out the release of Salesforce Instance<\/a><\/li>\n<li><a title=\"Quick way to find edition of Salesforce\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/11\/29\/quick-way-to-find-edition-of-salesforce\/\" target=\"_blank\" rel=\"noopener noreferrer\">Quick way to find edition of Salesforce<\/a><\/li>\n<li><a title=\"Invoke Future Methods through Apex Trigger for web service callout\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/10\/30\/invoke-future-methods-through-apex-trigger-for-web-service-callout\/\" target=\"_blank\" rel=\"noopener noreferrer\">Invoke Future Methods through Apex Trigger for web service callout<\/a><\/li>\n<li><a title=\"DateTime field and Time Zone Settings\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/10\/30\/datetime-field-and-time-zone-settings\/\" target=\"_blank\" rel=\"noopener noreferrer\">DateTime field and Time Zone Settings<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/12\/31\/get-key-prefix-of-an-object-using-apex\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[13,587,928,197,552,588,828,930,917,929],"class_list":["post-784","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-apex","tag-apex-object","tag-key-object-prefix","tag-key-prefix","tag-prefix-of-object","tag-salesforce-apex","tag-salesforce-object","tag-salesforce-object-type","tag-salesforce-standard-object","tag-standard-object-prefix"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=784"}],"version-history":[{"count":2,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/784\/revisions"}],"predecessor-version":[{"id":5682,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/784\/revisions\/5682"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}