You need to sign in to do that
Don't have an account?
Robert Wambold 10
Method does not exist or incorrect signature: void add(Id, List) from the type Map
My APEX trigger was timing out, so I thought I would to use a MAP, but I cannot get past the above error.
Anyone willing to take a look?
Map<Id,List<Opportunity>> accountOppMap = new Map<Id,List<Opportunity>>();
for(Opportunity opp : [Select id,accountId from opportunity Where Almac_Division__c='SI']){
List<Opportunity> opplst = AccountOppMap.get(opp.accountId);
if(opplst == null)
opplst = new List<Opportunity>();
opplst.add(opp);
accountOppMap.add(opp.accountId,opplst); <- error line
}
All Answers
Thank you so much for your help. May I ask another question?
The second part of my trigger needs to access the Map for a field, MyOpsPath__c then Update the Opportunity Object with information from the Account Object.
for(Account acc : trigger.new) {
if(acc.SI_Site_Reference__c!=null){
if((acc.Name != trigger.oldMap.get(acc.Id).Name) ||
(acc.Site != trigger.oldMap.get(acc.Id).Site) ||
(acc.SI_Site_Reference__c != trigger.oldMap.get(acc.Id).SI_Site_Reference__c)){
accountIds.add(acc.Id);
if (!accountIds.isEmpty()){
if ( accountOppMap.ContainsKey(accountIds) ) {
Opportunity.MyOpsPath=acc.Name;
Update Opporttunity;
}
}
}
}
}
It's a little difficult to tell how these variables are declared and what the exxact problem is, but this should be good start: