Get Salesforce SObject name through Salesforce Record Id

Author - Webner

Description: We have Salesforce recordId but need to identify what is the type of Subject 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 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 *