You need to sign in to do that
Don't have an account?
Shree K
need help with the trigger to send emails upon owner change
Hi ,
need help with the trigger to send emails upon Account owner change,
below is my trigger code,which is not working,
help will be appreciated,
need help with the trigger to send emails upon Account owner change,
below is my trigger code,which is not working,
help will be appreciated,
trigger EmailSend on Account (after insert,after update) { List<account> acclist = new set<account>(); For(account a:trigger.new){ If (a.ownerid != oldmap.get (a.id).ownerid) acclist.add (a.id); } Messaging.SingleEmailMessage mails = new Messaging.SingleEmailMessage(); for(account acc:acclist) { Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setTargetObjectId(acc.ownerid); mail.setTemplateId('templateid'); mail.setWhatId(acc.id); mail.setBccSender(false); mail.setUseSignature(false); mail.setSaveAsActivity(false); mails.add(mail); } Messaging.sendEmail(mails); }Thanks
Why can not you use Workflow to send email notification on Owner Change? Any specific reason for using Trigger.
Also, for above trigger, setup a debug log and check if you are getting some issue or not. Also add try-catch block to handle any exception.
-Thanks,
TK
What is templateid? i dont see any assignment to this variable ? get the template id by putting query on EmailTemplate and assign it to this variable.
Always prefer to accomplish your requirements with available salesforce configuration and if it is not possible then go for apex coding (trigger,batch etc)
Let us know if this will help you