You need to sign in to do that
Don't have an account?
Robert Wambold 10
Notify User when Queue limit is reached, then send an email once...only once. HELP!
Hello all,
So I created a trigger to Cases in a queue, when size is reached I want to send an email once..only once.
My trigger is firing at limit (3), but is sending the email 3 times. I think I need a second or third set of eyes to see what I am missing.
Thanks for your help.
Robert
trigger NotificationExceedingQueueLimit3 on Case (before insert,before update) { boolean EmailSent = False; list<group> queuelist= [SELECT id FROM Group where DeveloperName = 'CPS_Default_Queue'and Type = 'Queue' limit 1]; if(queuelist.size()>0){ list<case> caselist = [select id from case where ownerid =:queuelist[0].id]; for(case cs : trigger.new){ if(caselist.size()==3 && EmailSent == False) { EmailSent = True; List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>(); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); List<String> sendTo = new List<String>(); sendTo.add('Hello.Friend@gmail.com' ); mail.setHtmlBody('Hello, <br/> Default Queue Limit Exceeded. The count has exceeded 2 cases.<br/><br/> Thanks, <br/>Salesforce Admin'); mail.setSubject('Case Limit of 02 Exceeded'); mail.setToAddresses(sendTo); mails.add(mail); Messaging.sendEmail(mails); } } } }
All Answers
The below code will send only one email -
Hi Nish321,
I tried your code and on the 4th row (Caselist.size=4) I get 3 emails. :(
Thanks,
Robert