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
frank2anilfrank2anil 

Help with trigger

Hi 

 how to iterate over a map of values and check for the related opportunity and send a email.

trigger salestreenotification on Opportunity (after update) {

 


owner_relmailids.put(op.ownerid,new set<string>());


List<string>s =new List<String>();
for(Integer d=0;d<owner_relmailids.size();d++){ 
}

System.debug('**************************>>'+s);

messaging.Singleemailmessage mail=new messaging.Singleemailmessage();
mail.setToAddresses(s);
mail.setSenderDisplayName('Hult');
mail.setSubject('Opportunity Stage changed to:'+stgName);
mail.setPlainTextBody('The Application record '+Appname+'stage name was been changed to:'+StgName);
try{
messaging.sendEmail(new messaging.Singleemailmessage[]{mail});
}
catch(DMLException e){
system.debug('ERROR SENDING EMAIL:'+e);
}
}

 

I need to compare the opportunity id which i kept in stnmap with the ids in owner_relmailids.

owner_relmailids is contains opportunity owner id and related emails.

and then if both are same then need to send email to the related emails.

i was getting error incompatiable type in iteration so i made the for loop empty.

Could  any one help me.

 

JohnSchultzJohnSchultz

I answered this in your other thread, here: "instead-of-3-soql-need-a-method"