1

I have a process builder which runs when a record is created/edited. The object has various fields. The process builder runs only when a field named emailid is empty. The immediate action in the process builder is sending an email alert saying the email field is missing.

Problem: when I do a data load of 10,000 records and if all 10,000 record's emailid field is missing. Then the email alert is sent 10,000 times thereby flooding the concerned persons inbox. Is there a way that I can consolidate the records with missing emailid fields and send them in one email alert? IS there any approach?

2 Answers 2

1

Consider setting up a Report and then having the users to be notified Subscribe to Get Report Notifications.

Subscribe to a report to receive report notifications periodically when the metrics you care about most meet certain conditions. Set the conditions that trigger notification, and specify if you want to be notified via Salesforce1 notifications, Chatter, or email.

For example, you could subscribe to an open-issue report and get notified every morning if there are over 20 open issues. You can subscribe to notifications for up to five reports.

If you want to roll your own code to consolidate the errors, you'll need to write a batch class that implements Database.Stateful. No guarantee that with 10k records it would actually be able to maintain that much state. Alternatively, you could send one email per execute block. You can crank the scope size up to 2000 and only send out 5 emails instead of 10k.

5
  • If we have flexibility to use code then would you suggest a different approach?
    – SfdcBat
    Commented Aug 17, 2016 at 21:58
  • No. I would actually fight against using code here. It sounds like a royal pain that is not worth the effort. Sure, it can be done. That doesn't mean it should be done.
    – Adrian Larson
    Commented Aug 17, 2016 at 21:59
  • Ok, Is there a way to specify the email address to who this report should be sent? Or the person should log in to Salesforce and just subscribe to the report? Thanks
    – SfdcBat
    Commented Aug 17, 2016 at 22:11
  • The latter, they would log in and subscribe, or you would log in for them as a delegated user and subscribe that way.
    – Adrian Larson
    Commented Aug 17, 2016 at 22:12
  • Great, Thanks. This looks like a simple approach as you suggested.
    – SfdcBat
    Commented Aug 17, 2016 at 22:12
0

** forget this suggestion - didnt read question properly ** Given constraint of process builder (and no code), perhaps one approach (untested) might be to have another object called 'importJob', which you fire your email from. It has a long text field to aggregate the Ids of records with missing Ids. And a checkbox that when set fires the notification email.

On importJob add a workflow to send an email with the ids field merged into it when the importjob.sendalert checkbox is ticked.

Then on the actual records with email field, add a process to check for missing email at update/insert etc If email address missing then query for importjob record where counter < whatever batch size you want alerts for, and append record id to the aggregated ids text field plus increment counter. If counter = max batch size then also set the sendalert checkbox to true. If no query result then start a new importjob record with the current record id placed into text field.

This solution would then fire an alert every n records found with blank email addresses.

2
  • If we can used code then is there any alternative?
    – SfdcBat
    Commented Aug 17, 2016 at 21:56
  • Maybe rather than emailing people, a report as mentioned by Adrian, and a home page dashboard element or custom Sidebar component that notifies at login and has a link to simple report. This removes the risk of emails just being ignored anyway, and solution stays clear of process builder etc adding transaction overhead unnecessarily. Commented Aug 17, 2016 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .