{"id":96,"date":"2013-11-02T18:29:34","date_gmt":"2013-11-02T18:29:34","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=96"},"modified":"2024-08-05T05:55:29","modified_gmt":"2024-08-05T05:55:29","slug":"get-key-prefixobject-id-of-object-in-javascript","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2013\/11\/02\/get-key-prefixobject-id-of-object-in-javascript\/","title":{"rendered":"Get Key Prefix\/Object id of Object in JavaScript"},"content":{"rendered":"<p>Few days back, while working on a project we needed to have a Key Prefix of our Object called Client__c in our JavaScript code for further processing. We didn\u2019t want to hard code Key Prefix of Client__c. The reason is that when we deploy our package for different Organizations, Key Prefix would automatically get created. It could be anything but the object name would remain the same i.e. Client__c<b>.<\/b><\/p>\n<p><span style=\"color: #800000;\"><span style=\"color: #000000;\"><em><strong>New Stuff<\/strong><\/em>\u00a0<\/span>:<\/span>\u00a0\u00a0<a title=\"Mapping custom lead fields to standard contact fields\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2013\/11\/01\/mapping-custom-lead-fields-to-standard-contact-fields\/\" target=\"_blank\" rel=\"noopener\">Mapping custom lead fields to standard contact fields<\/a><\/p>\n<p><span style=\"line-height: 1.6em;\">Here<\/span><b style=\"line-height: 1.6em;\"> <\/b><span style=\"line-height: 1.6em;\">is the<\/span><b style=\"line-height: 1.6em;\"> <\/b><span style=\"line-height: 1.6em;\">code snippet to get the<\/span><b style=\"line-height: 1.6em;\"> <\/b><span style=\"line-height: 1.6em;\">Key Prefix of Object called Client__c that we found after searching &#8211;<\/span><\/p>\n<p><b>force. connection.sessionId = &#8216;{!$Api.Session_ID}&#8217;;<\/b><\/p>\n<p><b>var result = sforce.connection.describeSObjects([&#8220;Client__c&#8221;]);<\/b><\/p>\n<p><b>var clientPrefix = result[0].keyPrefix;<\/b><\/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 require 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","protected":false},"excerpt":{"rendered":"<p>Few days back, while working on a project we needed to have a Key Prefix of our Object called Client__c in our JavaScript code for further processing. We didn\u2019t want to hard code Key Prefix of Client__c. The reason is that when we deploy our package for different Organizations, Key Prefix would automatically get created.\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2013\/11\/02\/get-key-prefixobject-id-of-object-in-javascript\/\">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":[197,245,551,552],"class_list":["post-96","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-key-prefix","tag-object-id","tag-object-in-javascript","tag-prefix-of-object"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/96","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=96"}],"version-history":[{"count":6,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":8881,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/96\/revisions\/8881"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}