Wednesday, June 12, 2019

How to get sObject details using Record Id in Apex

Example:
Id idRec = '0060o00001GiaUGAAZ';
Schema.sObjectType sObjType = idRec.getSObjectType();
Schema.DescribeSObjectResult sObjDescribeResult = sObjType.getDescribe();

System.debug('Obj Name ===> '+sObjDescribeResult.getName());
System.debug('Obj key prefix ===> '+sObjDescribeResult.getKeyPrefix());
System.debug('Obj plural Name ===> '+sObjDescribeResult.getLabelPlural());

Result

No comments:

Post a Comment