The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged


finally found for(SObjectType objFields: Database.query(theQuery)){ (String)objFields.getSObject('parent__r').get('field1__c') }


You need to use SObject as the value, not Object. Map<Id, SObject> opportunities = new Map<Id, SObject>(Database.query(...));


Static and dynamic SOQL need appropriately typed bindings. For this to work you need the "listOfIds" to be one of: List<String> List<Id> or even: List<Account> (where the Account instances include at least the Id field)


SOQL in Apex does not, by default, honor profile permissions. To do so, add WITH SECURITY_ENFORCED. As the documentation says: Apex generally runs in system context; that is, the current user's permissions, field-level security, and sharing rules aren’t taken into account during code execution. Although performing field- and object-level security checks ...

Top 50 recent answers are included