Mass Delete SMS Records
  • 27 Feb 2023
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Mass Delete SMS Records

  • Dark
    Light

Article summary

Mass Delete SMS Records

Follow these steps to mass delete SMS or Async Task records.

Before Beginning

Prior to proceeding, you will need to consult your System Administrator about the mass deletion of any records in your organization. It’s likely they will need to assist you with this process.

This guide walks you through two methods of deleting SMS records. Option 1 is to use an in-app button. Option 2 is to run a line of code in the developer console (system admin privileges required).

If you are removing SMS records from a bulk send or intelligent route, you will need to remove the associated Async Task records first. If these are not removed, Mogli will continue to attempt sending the bulk message. Follow the steps in the Mass Delete Async Task Records section prior to deleting SMS records.

OPTION 1: Delete SMS with the In-App Button

This option allows you to manually select up to a few hundred records from the SMS list view to delete. If you want to mass delete all records at a quicker pace, and do not need to hand-select, we recommend using the Developer Console Code option in the next section.

To mass delete any records, you will need to ensure you have the Mogli SMS User: System Admin permission set assigned to yourself. Not a system admin? Reach out to your internal admin for assistance.

Go to Setup > Object Manager

Type SMS in the quickfind box and press Enter. Click on SMS.

Click on Search Layouts for Salesforce Classic.

Click Edit in the dropdown on the right-hand side of List View.

Move the Mass Delete button from Available to Selected. Click Save.

Using the App Launcher, search Mogli and click on MogliSMS Lightning.

Click on the SMS tab. Choose the list view you’d like to delete messages from.

Use the checkboxes on the left hand side to select which records to delete. BE SURE that these are the correct records!

Click Mass Delete.

If you are sure, click Delete Records.

ADMIN TIP: If you would like this button to be accessed by Admins only, follow the next few steps. This doesn't hide the button from users, but does get rid of the access for users.

Go into the Setup > Profiles > (Choose the profile that shouldn't be able to mass delete SMS records) > Visualforce Page Access and remove the Mogli_SMS.SMSMassDelete page.

The button will show on the list view, but if a user tries to use it they'll see a page that says "Insufficient Privileges"

OPTION 2: Delete SMS with the Developer Console

Click the gear icon in the top right. Click Developer Console.

In the Debug dropdown, click Open Execute Anonymous Window.

Paste in one of the lines of code below into the new window.


Option 1: To delete 10,000 (or less) SMS records in Queued status, paste in this code:


delete [SELECT Id FROM Mogli_SMS__SMS__c WHERE Mogli_SMS__Status__c = 'Queued' LIMIT 10000];

Option 2: To delete 10,000 (or less) SMS records in Scheduled status, paste in this code:

delete [SELECT Id FROM Mogli_SMS__SMS__c WHERE Mogli_SMS__Status__c = 'Scheduled' LIMIT 10000];

Click Execute.

Double-check that the Queued and/or Scheduled SMS records are deleted in Salesforce.

Note: This line of code deletes 10,000 records. If you have more than 10,000 records to remove, you will need to execute the code multiple times.

Mass Delete Async Task Records

Our bulk send architecture requires the creation and utilization of Async Task records. This step is necessary if you deleted SMS records from a bulk send (or intelligent route) in the previous steps. Consult your System Administrator prior to proceeding.

Click the gear icon in the top right. Click Developer Console.

In the Debug dropdown, click Open Execute Anonymous Window.

Paste this line of code into the new window:

delete [SELECT Id FROM Mogli_SMS__AsyncTaskManager__c LIMIT 10000];

Click Execute.

Note: This line of code deletes 10,000 records. If you have more than 10,000 records to remove, you will need to execute the code multiple times.


Was this article helpful?