Skip to content

Instantly share code, notes, and snippets.

@jamesasu
Created February 23, 2021 01:30
Show Gist options
  • Save jamesasu/ee8f9a7e5818ad3508872fa8611056a2 to your computer and use it in GitHub Desktop.
Save jamesasu/ee8f9a7e5818ad3508872fa8611056a2 to your computer and use it in GitHub Desktop.
public static String getIconName(String sObjectName){
String u;
List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();
List<Schema.DescribeTabResult> tabDesc = new List<Schema.DescribeTabResult>();
List<Schema.DescribeIconResult> iconDesc = new List<Schema.DescribeIconResult>();
for(Schema.DescribeTabSetResult tsr : tabSetDesc) { tabDesc.addAll(tsr.getTabs()); }
for(Schema.DescribeTabResult tr : tabDesc) {
if( sObjectName == tr.getSobjectName() ) {
if( tr.isCustom() == true ) {
iconDesc.addAll(tr.getIcons());
} else {
u = 'standard:' + sObjectName.toLowerCase();
}
}
}
for (Schema.DescribeIconResult ir : iconDesc) {
if (ir.getContentType() == 'image/svg+xml'){
u = 'custom:' + ir.getUrl().substringBetween('custom/','.svg').substringBefore('_');
break;
}
}
return u;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment