It is possible to run query and the results inserted into an Apex list:
List<Opportunity> opportunities = [SELECT Opportunity.OwnerId,
Opportunity.Probability,
Owner.Name FROM Opportunity
WHERE Opportunity.LastModifiedDate = LAST_N_DAYS:7];
Is it possible to return a Map? Where the key would be the OpportunityID and the value the Opportunity?
If not, what is the quickest way to convert to a map?
List<Opportunity> oppList = [Select Id, AccountId from Opportunity]; Map<Id,Opportunity> accOppMap = new Map<Id,Opportunity>(); for(Opportunity o : oppList){ accOppMap.put(o.AccountId,o); }– Todd Sprinkel May 04 '15 at 15:13Map<AccountId, List> m = new Map<AccountId, List>([SELECT Id (SELECT Id FROM Contacts) FROM Account]);
– Nitish Kulkarni Dec 16 '20 at 13:45result--> 0016F00002THXyjQAH=Account:{Id=0016F00002THXyjQAH, Name=test1, CreatedDate=2018-09-03 12:33:32, CurrencyIsoCode=USD}
– Shakti Jadon Apr 06 '21 at 20:04