New answers tagged


You can use simple bind variables in dynamic SOQL query strings. So it would work if you change the query as follows. Database.query('SELECT '+accQueryString+' FROM Account WHERE id = :recId');


Try: public class Test { public static void testme(String obj){ string query = 'select name '; query=query + ' from ' + obj ; query=query + ' limit 1'; system.debug('query===='+query); list<sobject> accounts=database.query(query); } } Take note of spaces in strings.


You cannot append the list string. You need to parse the list into and string and then append it to the query string. Here are the updates to the code: List<String> sObjFields = DynamicSOQL.getFields('Contact'); String allstring = string.join(sObjFields,','); String query2 = 'SELECT ' + allstring + ' FROM Contact';


You need to explicitly get the list of related objects via getSObjects() method for (ScheduledBillRun__c sbr : scope) { System.debug(sbr.getSObjects('Invoices__c')); }


If you look at the documentation on Condition Expression Syntax (WHERE Clause), you will see that the correct syntax is to use AND or OR to join conditions. WHERE Field1__c = 'value1' AND Field2__c = 'value2' AND Field3__c = 'value3'

Top 50 recent answers are included