Skip to content

Instantly share code, notes, and snippets.

@unidha
Last active September 2, 2015 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unidha/db3c91dcfb8a42d74bb2 to your computer and use it in GitHub Desktop.
Save unidha/db3c91dcfb8a42d74bb2 to your computer and use it in GitHub Desktop.
RecentlyViewed[] recents = [
SELECT Id, Name
FROM RecentlyViewed
ORDER BY LastViewedDate DESC
LIMIT 10
];
Set<String> types = new Set<String>();
for (RecentlyViewed r : recents) {
types.add(String.valueOf(r.Id.getSObjectType()));
}
system.debug('@Checking types'+ types);
// Get tab set describes for each app
List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();
Set<String> tabObject = new Set<String>();
// Iterate through each tab set describe for each app and display the info
for(DescribeTabSetResult tsr : tabSetDesc) {
String appLabel = tsr.getLabel();
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('@NUR objectName :'+tr.getSobjectName());
if(types.contains(tr.getSobjectName())){
tabObject.add(tr.getSobjectName());
System.debug('@Checking type :'+tr.getSobjectName());
/*System.debug('@Checking getLabel: ' + tr.getLabel());
System.debug('@Checking getColors: ' + tr.getColors());
System.debug('@Checking getIconUrl: ' + tr.getIconUrl());
System.debug('@Checking getIcons: ' + tr.getIcons());
System.debug('@Checking getMiniIconUrl: ' + tr.getMiniIconUrl());
System.debug('@Checking getSobjectName: ' + tr.getSobjectName());
System.debug('@Checking getUrl: ' + tr.getUrl());
System.debug('@Checking isCustom: ' + tr.isCustom());*/
}
}
}
system.debug('@Checking tabObject '+tabObject);
//Result:Note in my RecentlyView I got 3 object name, but in DescribeTab only 1 object which is Account
/***
DEBUG|@Checking types{Account,ListView, User}
DEBUG|@Checking tabObject {Account}
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment