function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sheila srivatsavsheila srivatsav 

Ma<ID,List<Opportunities>> concept

I have a list of opportunities inside a list as follows

List<Opportunities> opporList= new List<Opportunities>([select ID,Name,Amount from Opportuntities)];

Now I have the following : Map<ID,Account> accMap=new Map<ID,Account>();

Now I wanto to seggregate accountID and productiD from the list.
Best Answer chosen by sheila srivatsav
Ajay K DubediAjay K Dubedi
Hi Sheila

Refer the below code.
 
List<Opportunity> opps = new list<Opportunity>([Select Id,AccountId, (Select Id, name From OpportunityLineItems) From Opportunity]);
//now you can seggrigate the both Account and Product2Id Like this 
ste<Id> setid=new set<Id>();
  for(opportunity opp:opps)
  {
   setid.add(opp.AccountId);
  } // get your Product2Id as well
  
Mark it as a best if it helps you.

Thanks,
Ajay Dubedi