Home SALESFORCEAPEX How to Find Salesforce Object ID Prefix using apex class?

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.

You may also like

Leave a Comment