List<String> allCustomObjsList = new List<string>();
List<String> allStandardObjsList = new List<string>();
for(Schema.SobjectType obj : Schema.getGlobalDescribe().values()) {
Schema.DescribeSobjectResult objResult = obj.getDescribe();
if(objResult.isCustom()) {
String strObjName =objResult.getname();
allCustomObjsList.add(strObjName);
}
else {
String strObjName =objResult.getname();
allStandardObjsList.add(strObjName);
}
}
System.debug('Custom Objects List: ' +allCustomObjsList);
System.debug('Standard Objects List: ' +allStandardObjsList);
If you need to check for a specific object, execute the below code:
Schema.DescribeSObjectResult describeAccount = Schema.sObjectType.Account;
System.debug(describeAccount.isCustom());
Similarly you can use other methods for describing sObjects, the list of which can be found below:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject_describe.htm
0 comments:
Post a Comment