How to Find Salesforce Object ID Prefix using apex class?

In salesforce every stranded and custom object has specific id.
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.

Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

Your email address will not be published. Required fields are marked *