public static SObject[] selectAll(String objName, String additionalFilters){
//get object fields
List<String> fieldList = new List<String>(Schema.getGlobalDescribe()
.get(objName).getDescribe().fields.getMap().keySet());
String fields = String.join(fieldList,',');
return (SObject[])Database.query(
'SELECT '+fields+' FROM '+objName+ ' '+additionalFilters
);
}
System.debug( Helper.selectAll('Account', 'Order by CreatedDate Limit 10'));
Concepts or coding lessons of Salesforce that you can implement easily
Select * from X on apex (SOQL) in Salesforce
Subscribe to:
Posts (Atom)