Dynamic SOQL based on Sobject Name and Where Clause
public class DynamicSOQLUtil { // Returns a dynamic SOQL statement for the whole object, based on object name and where clause as a dynamic public static string getCreatableDynamicFieldsSOQL(String objectName, String whereClause){ String selects = ''; // Check whereclause if null then return null if (whereClause == null || whereClause == ''){ return null; } // Get a map of field name and sobject field Map<String, Schema.SObjectField> objFieldMap = Schema.getGlobalDescribe().get(objectName.toLowerCase()).getDescribe().Fields.getMap(); list<string> selectFields = new list<string>(); if (objFieldMap != null){ for (Schema.SObjectField objFt : objFieldMap.values()){ // loop through all field tokens Schema.DescribeFieldResult fd = objFt.getDescribe(); //field describe for each field //if (fd.isCreateable()){ // if needed onl