Is Email Scrubber Right for You?… Let’s Audit Your Instance

We believe Email Scrubber will quickly become your new friend. It will work tirelessly to continuously reduce the burden (and extra costs) associated with redundant email message in your instance. But don’t take our word for it. Take Email Scrubber for a spin and see what type of savings you can expect.

Note ready to run the audit on your own? No problem. Give us a ping and we can run it on your behalf.

First and foremost, you have to install Email Scrubber. Head on over to AppExchange and install Email Scrubber into your instance.

Once installed, Email Scrubber provides an array of options to configure the application. But don’t worry. The first step is painless. Navigate to Setup > Custom Code > Custom Metadata Types and you will find out Declutter Setup CMDT.

Once in the CMDT, locate the Retro Batch > Retro Batch Where Condition entry. Modify the where condition to isolate the email messages you wish to audit.

Note: To adhere to the Salesforce governor limits, we find it helpful in most instances to run the audit for a year of data at a time. The where condition above runs the audit for all email messages related to a case, there the case was created in 2020.

Once the CMDT has been updated, run the batch process for a single execution. Log into the Developer Console (Gear Icon > Developer Console > Debug -> Open Execute Anonymous Window), enter the following script:

emailscrubber.retroBatch batchApex = new emailscrubber.retroBatch();
id batchprocessid = Database.executeBatch(batchApex);

and click on the execute button.

Note: If you wish to run the process for multiple executions (such as multiple years), simple wait for the Apex Job to complete, and repeat the process.

If you are leveraging Salesforce Inspector (or any other apps that can handle an Aggregate Query against your instance, then run the following:

select CALENDAR_YEAR(parent.createddate) yr, count(id) cnt
from emailMessage
where EmailScrubber__duplicate_detected__c = true
and parentId != null
GROUP BY CALENDAR_YEAR(parent.createddate)
ORDER BY CALENDAR_YEAR(parent.createddate)

As an alternative, you can run the following in the Developer Console and view the results in the log,

AggregateResult[] groupedResults  = [SELECT CALENDAR_YEAR(messageDate) yr, COUNT(id) cnt
                                     FROM emailMessage
                                     WHERE emailScrubber__duplicate_detected__c = true
                                           and parentId != null
                                     GROUP BY CALENDAR_YEAR(messageDate)
                                     ORDER BY CALENDAR_YEAR(messageDate) asc];

for (AggregateResult ar : groupedResults)  {
    System.debug(‘—–Year ‘ + ar.get(‘yr’));
    System.debug(‘—–Count ‘ + ar.get(‘cnt’));