Created
February 23, 2021 01:30
-
-
Save jamesasu/ee8f9a7e5818ad3508872fa8611056a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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