Salesforce

Salesforce

Reusable Related List Lightning Component with filter in Salesforce

Sample Code: Apex Class: public class RelatedListController {              @AuraEnabled       public static RelatedListResult fetchRecs( String recId, String sObjName, String parentFldNam, String strCriteria ) {                      String strTitle = ' (';                    List < sObject > listsObjects = new List < sObject >();           RelatedListResult obj = new RelatedListResult();           String strSOQL = 'SELECT Id FROM ' + sObjName + ' WHERE ' + parentFldNam + ' = '' + recid + ''';           if ( String.isNotBlank( strCriteria ) )               strSOQL += ' ' + strCriteria;           strSOQL += ' LIMIT 4';           listsObjects = Database.query( strSOQL );             Integer intCount = listsObjects.size();           if ( intCount > 3 ) {                              List < sObject > tempListsObjects = new List < sObject >();               for ( Integer i = 0; i <3; i++ )                   tempListsObjects.add( listsObjects.get( i ) );                              obj.listsObject = tempListsObjects;               strTitle += '3+';   ....