Find a Salesforce Object type from a Salesforce Record ID

If you’ve got a Salesforce record Id, need to quickly find out what object type the record is, then you can use the following snippet via execute anonymous in your Salesforce org. You just replace the myRecordId value with the Record ID that you’re working with.

Id myRecordId = '003Qy000008ZanCIAS'; 
System.debug('sObjectType is: '+ myRecordId.getsobjecttype());

Leave a Reply