File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11public class QueryUtils {
2+ public static String getSObjectQuery (String sobjectApiName ) {
3+ Schema .SObjectType sobjectType = Schema .getGlobalDescribe ().get (sobjectAPIName );
4+
5+ List <String > fields = new List <String >();
6+ Map <String , Schema .SObjectField > fieldMap = sobjectType .getDescribe ().fields .getMap ();
7+ for (Schema .SObjectField sobjectField : fieldMap .values ()) {
8+ fields .add (sobjectField .getDescribe ().getName ());
9+ }
10+
11+ return buildQuery (sobjectApiName , fields );
12+ }
13+
14+ private static String buildQuery (String sobjectApiName , List <String > fields ) {
15+ String queryFields = String .join (fields , ' , ' );
16+ String query = ' SELECT ' + queryFields
17+ + ' FROM ' + sobjectApiName ;
18+
19+ return query ;
20+ }
21+
222 private static String getQueryFields (List <Schema .FieldSetMember > fieldSet ) {
323 String queryFields = ' ' ;
424 for (Schema .FieldSetMember field : fieldSet ) {
You can’t perform that action at this time.
0 commit comments