Identify SObject Name with Record Id

Ever wondered how to find Salesforce Object name with Record Id?

Here is solution,

// pass record Id for which you want to find sObject Name
Id recordId = 'a099000000h6Nw9'; 
// recordId.getSObjectType() is responsible for getting sObject Name
system.debug(recordId.getSObjectType());

Happy Coding!!!

Subscribe to Phanindra Mangipudi

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe