Get Salesforce SObject name through Salesforce Record Id

|
| By 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);
}

Leave a Reply

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