Get Salesforce SObject name through Salesforce Record Id

Author - Webner

Description : We have Salesforce recordId but need to identify what is the type of Sobject corresponding to this record id.

Solution : We can get Sobject name from recordId with getSobjectType() function, sample code below:

Apex Code :

public void echoSObjectName(String RecID)
{
    objName = RecID.getSobjectType();
    System.debug('Object Name is ' + objName);
}

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need Salesforce customization, App development or any other software development assistance please contact us at salesforce@webners.com

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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