Skip to main content

Posts

Showing posts with the label how to get 3 digit id of an object in salesforce

How to get key prefix of an Object in Salesforce.

We know there are two types of record-id are present in salesforce. 15 digit -- Case Sensitive 18 digit -- Case Insensitive Only 3 digit of ids represent object type . for example  Account-- 001 Contact-- 003 Opportunities --006 Lead  --- 00Q How will get these prefix dynamically, I mean by using apex code ? Schema.Describe SObjectResult r = CustomObject__c .sObjectTy pe.getDescribe( ); String keyPrefix = r.getKeyPrefix( ); System.debug('P rinting --'+keyPrefix ); It will print prefix of Custom Object id.