You need to sign in to do that
Don't have an account?

After insert sending too many emails
I have a trigger on Account to send email notification after mass update is complete.
But I am getting multiple email notification because Salesforce Trigger is processing 200 at a time. Any suggestions on how I can only send one email instead of multiple (1 for every 200)
We are getting weekly data to load into Salesforce. Need to notify sales team after the upload is complete. But the above sample code is generating 5 emails, 1 for every 200 records. I tried is isBatch(), the values is FALSE in this scenario.
Any suggestions ?
But I am getting multiple email notification because Salesforce Trigger is processing 200 at a time. Any suggestions on how I can only send one email instead of multiple (1 for every 200)
trigger AccountTriggers on Account (before Insert, after update, after insert){ //Email Notification after mass upload Complete if(!recordIds.isEmpty() && recordIds.size() > 100){ ASA_SubgroupTrigger_EmailNotification.SendEmailToSalesTeam(); } }I tried with DbAmp, Apex dataloader. I have over 800 records. I got 5 email notification when I loaded my records.
We are getting weekly data to load into Salesforce. Need to notify sales team after the upload is complete. But the above sample code is generating 5 emails, 1 for every 200 records. I tried is isBatch(), the values is FALSE in this scenario.
Any suggestions ?
[1] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
[2] https://help.salesforce.com/apex/HTViewHelpDoc?id=cs_about.htm
If you are sure that the entire data load is occuring in a single transaction you can always create a class level static variable and use that to "lock" your email notifications for the transaction. For example
EmailUtils.cls
Code in trigger
This will ensure that it only runs once for the entire transaction.