Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

How to Find Salesforce Object ID Prefix using apex class?

Be First!

How to Find Salesforce Object ID Prefix using apex class?

In salesforce every stranded and custom object has specific id.
i.e:
first 3 digits of an Id is an identifier prefix for object and record (both standard and custom object)

Some Few example:
Account – 001
Contact – 003
Opportunity – 006
User – User

Steps for find Salesforce Object ID prefixes in developer console

First open developer console (Click Your Name and Click Developer Console).
Click Debug and Open Execute Anonymous Window or CTRL+E.
Enter Below code in Anonymous Window and execute.
//change Account with your object API name
system.debug(‘Prifix::’ + Account.sobjecttype.getDescribe().getKeyPrefix());
Change Account name with your object API name (i.e Student__c OR Account)

Find 3 digit object id in Debug log.

(3)

Previous
Next

Leave a Reply