Sunday, July 2, 2017

How to find object type from Salesforce record id?

Hi,

In some cases you can get the details of the object based  on the record id, in such scenarios we can achive with Dynamic apex using SobjectType class.

in the below code snippet based on account record id it is going to display the object name in debug console.

//0019000001AE8dn is my organization account id.
Id recId = '0019000001AE8dn'; 
Schema.SObjectType objType = recId.getSobjectType();
 System.debug('Object Type is ' + objType);

No comments:

Post a Comment