Get Key Prefix/Object id of Object in JavaScript

By | November 2, 2013

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’t 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.

New Stuff :  Mapping custom lead fields to standard contact fields

Here is the code snippet to get the Key Prefix of Object called Client__c that we found after searching –

sforce.connection.sessionId = ‘{!$Api.Session_ID}’;

var result = sforce.connection.describeSObjects([“Client__c”]);

var clientPrefix = result[0].keyPrefix;

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.