To provide sObject details and their fields
- johnsontitus
- May 24, 2020
- 1 min read
/*
//to return a map of all sObject names(Keys) to sObject tokens(values)
Map<String, Schema.SObjectType> globalDescribes = Schema.getGlobalDescribe();
System.debug('The sObject, whose name is Case is of type ' + globalDescribes.get('case'));
System.debug('The sObject, whose name is Account is of type ' + globalDescribes.get('account'));
//to describe a sObject(s)
Schema.DescribeSObjectResult[] descResult = Schema.describeSObjects(
new String[]{'Account','Contact'});
System.debug(descResult);
for(Schema.DescribeSObjectResult r : descResult){
System.debug(r.getName());
}
*/
/*
// Get tab set describes for each app
List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();
// Iterate through each tab set describe for each app and display the info
for(DescribeTabSetResult tsr : tabSetDesc) {
String appLabel = tsr.getLabel();
if (appLabel == 'Sales') {
System.debug('Label: ' + appLabel);
System.debug('Logo URL: ' + tsr.getLogoUrl());
System.debug('isSelected: ' + tsr.isSelected());
String ns = tsr.getNamespace();
if (ns == '') {
System.debug('The ' + appLabel + ' app has no namespace defined.');
}
else {
System.debug('Namespace: ' + ns);
}
// Display tab info for the Sales app
List<Schema.DescribeTabResult> tabDesc = tsr.getTabs();
System.debug('-- Tab information for the Sales app --');
for(Schema.DescribeTabResult tr : tabDesc) {
System.debug('getLabel: ' + tr.getLabel());
System.debug('getColors: ' + tr.getColors());
System.debug('getIconUrl: ' + tr.getIconUrl());
System.debug('getIcons: ' + tr.getIcons());
System.debug('getMiniIconUrl: ' + tr.getMiniIconUrl());
System.debug('getSobjectName: ' + tr.getSobjectName());
System.debug('getUrl: ' + tr.getUrl());
System.debug('isCustom: ' + tr.isCustom());
}
}
}
*/
Schema.DescribeFieldResult F = Account.Industry.getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();
for (Schema.PicklistEntry pe : p){
System.debug(pe.getLabel());
}

Comments