Get Salesforce SObject name through Salesforce Record Id

|
| By 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

Leave a Reply

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