@@ -14,8 +14,13 @@ public with sharing class RelatedList {
1414
1515
1616 @AuraEnabled
17- public static ListResults getRecords (String soql , String SObjectName ) {
18- return new ListResults (Database .query (soql ), getIconName (SObjectName ));
17+ public static ListResults getRecords (String soql , String SObjectName , String iconName ) {
18+ // autoretrieve of the icon name based on sobject name if no icon is specified
19+ if (String .isBlank (iconName ) ) {
20+ iconName = IconUtils .getIconName (SObjectName );
21+ }
22+
23+ return new ListResults (Database .query (soql ), iconName );
1924 }
2025
2126 @AuraEnabled(cacheable= true )
@@ -30,30 +35,4 @@ public with sharing class RelatedList {
3035 return 0 ;
3136 }
3237
33- public static String getIconName (String sObjectName ){
34- String u ;
35- List <Schema .DescribeTabSetResult > tabSetDesc = Schema .describeTabs ();
36- List <Schema .DescribeTabResult > tabDesc = new List <Schema .DescribeTabResult >();
37- List <Schema .DescribeIconResult > iconDesc = new List <Schema .DescribeIconResult >();
38-
39- for (Schema .DescribeTabSetResult tsr : tabSetDesc ) { tabDesc .addAll (tsr .getTabs ()); }
40-
41- for (Schema .DescribeTabResult tr : tabDesc ) {
42- if ( sObjectName == tr .getSobjectName () ) {
43- if ( tr .isCustom () == true ) {
44- iconDesc .addAll (tr .getIcons ());
45- } else {
46- u = ' standard:' + sObjectName .toLowerCase ();
47- }
48- }
49- }
50- for (Schema .DescribeIconResult ir : iconDesc ) {
51- if (ir .getContentType () == ' image/svg+xml' ){
52- u = ' custom:' + ir .getUrl ().substringBetween (' custom/' ,' .svg' ).substringBefore (' _' );
53- break ;
54- }
55- }
56-
57- return u ;
58- }
5938}
0 commit comments