Loading

How to Use Apex to Clean Up Individual Email Results

Дата публикации: Jan 27, 2025
Решение
Steps to delete Individual Email Results:
  1. Save the IERCleanup class in your organization:
  2. Open the Developer Console under Your Name or the quick access menu ().
  3. In the Developer Console, click File | New | Apex Class, and enter IERCleanup for the class name, and then click OK.
  4. Replace the default class body with the IERCleanup class example. Insert the Criteria for deleting IER records or delete the [Criteria] if you want to delete all the records.
As an example, if you wish to delete IERs for emails sent over a year ago, kindly substitute the line that has the criteria with the line provided below.
et4ae5__IndividualEmailResult__c  [] IERsToDelete = [SELECT ID FROM et4ae5__IndividualEmailResult__c where et4ae5__DateSent__c> LAST_N_DAYS:365];
 
public class IERCleanup {
    public void deleteIERs() {
        // Query for the Individual Email Results you want to delete
        // In this example, we're deleting all Individual Email Results that match the criteria
        et4ae5__IndividualEmailResult__c  [] IERsToDelete = [SELECT Id FROM et4ae5__IndividualEmailResult__c where [Criteria]];
        
    try {
    delete IERsToDelete;
} catch (DmlException e) {
    // Process exception here
}                        }
}
  1. In the Developer Console, click Debug | Open Execute Anonymous Window.
  2. In the window that opens, enter the following.
IERCleanup ie = new IERCleanup();
ie.deleteIERs();
  1. Click Execute.
Номер статьи базы знаний

000396019

 
Загрузка
Salesforce Help | Article