How to get the 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 digits of
ids represent object type.
For example
:-
- Account - 001
- Note - 002
- Contact - 003
- Opportunities - 006
- Lead - 00Q
Q: How will get
these prefix dynamically, I mean by using Apex code?
Ans: Schema.DescribeSObjectResult
r = CustomObject__c.sObjectType.getDescribe();String keyPrefix =
r.getKeyPrefix();System.debug('***ObjectKeyPrefix***'+keyPrefix );
Good Post
ReplyDelete