is it possible to do SOQL for the unknown object without for loop as below
string theQuery = 'Select '+fiels+' From'+obj_frm +whr;
Map <Id, object> oppMap = new Map<Id, object>((List<object>)Database.query(theQuery));
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityYou need to use SObject
as the value, not Object
.
Map<Id, SObject> opportunities = new Map<Id, SObject>(Database.query(...));