Using GRAX to delete data from Salesforce
GRAX Archive provides you tooling to easily delete data from Salesforce with confidence.
Archived records are still available in GRAX for search, visualization and restore—just like any other record deleted directly via Salesforce. But by using GRAX to archive records you can count on us to take care of the usual concerns that come with data deletion, like auditing, capacity planning and data integrity.
The foundation for this is Auto Backup, which ensures GRAX has the latest version of all your records. This means things like triggers and cascade deletes aren't going to unexpectedly cause data loss.
GRAX strongly recommends you first archive and restore a single EmailMessage to understand the tools and to expose any permission problems deleting and inserting data in Salesforce.
To archive your first record in the GRAX webapp:
- Enable Auto Backup.
- In the Record Viewer, look for an EmailMessage record and click the "Archive" button
- Keep the default option "Verify records individually with Salesforce"
- Look at the confirmation; that shows a plan with what data and files are going to be deleted
- Click "Execute" and GRAX:
- Verifies the record and related data is backed up
- Deletes the provided records and orphaned files
- Updates the record and related data in GRAX to reflect its latest status
After this is done you can open the record again to restore it.
The Archive Dashboard provides a graphical view of Salesforce storage usage over time as well as an archive record count.
The "Show Storage Total" toggle displays the sum of object and file storage usage if enabled. If disabled, those two storage types are displayed independently. Similarly to the backup dashboard, the display of each data type can be enabled or disabled by clicking on that data type in the dashboard legend.
By default GRAX relies on Salesforce to delete related records, via cascade deletes. So when you request a
Case to be archived, for example, you'll notice that related Events and Tasks are also going to be deleted.
That aside, the one case where we may delete additional records in an archive is to clean up
ContentDocument records that would be left orphaned. This is important because while the cascade delete takes care of deleting files represented by an
ContentDocument hierarchy is a bit different and would allow for orphaned records and files to be left in Salesforce.
Archive by SOQL
The GRAX webapp offers another way to archive one or more records by a SOQL statement.
- In the webapp, select "Archive" which takes you to the "Archive by SOQL" workflow
- Enter a SOQL statement to select IDs to archive, for example
SELECT Id FROM EmailMessage ORDER BY CreatedDate ASC LIMIT 1
- This selects the oldest single EmailMessage live in SFDC
- Continue through the Archive Options and Confirmation screen as above.
SOQL queries support
LIMIT and default to
100 if not specified, for safety reasons. The max
LIMIT of a single archive operation is
To archive more records than this, click into the archive job and click on "Set up Auto Archive"; check off the "enabled" option and save the changes which allows the archive job to run as many times as needed until the all records matching the criteria have been archived. This automatically runs the archive job anytime new records matching the criteria are found.
Please note that Auto Archive can only be setup for archive jobs initiated via SOQL query.
Review your SOQL statements and archive confirmations carefully before running large or automatic archives. GRAX tooling can not detect queries that may impact your business like deleting many open active Cases.
After this you can review any archive job to perform a batch restore.
How It Works
Archive are performed by the GRAX integration user, which requires "Modify All Data" permissions to be able to delete records. Once you start an archive, GRAX:
- Collects the "parent" object ID or IDs
- Introspects the parent object schema to collect "child" object IDs based on "master detail" relationships
- Applies your archive verification choice
- Generates a preview of all parent and child records counts that are to be deleted for confirmation
- Issues batches of "Cascade Delete" API calls to Salesforce which deletes parents and relationships
- Provides a summary of how many records were deleted and what errors if any were returned
The recommended way to prevent data loss when deleting records with GRAX is to pick "Verify records individually with Salesforce" when running archives. In this mode GRAX issues SOQL queries to get information about records that may be deleted with the archive hierarchy, and then ensures that Auto Backup has them covered.
This is extremely important when you aren't sure about the shape of the data being deleted, or when you are archiving records that may still change.
There is a faster option available, though, for when you know the data being deleted is stable and cannot change. For example, when archiving email messages via a SOQL query that only returns records created years ago, in most environments this record isn't expected to receive updates so you can archive it faster by picking "Verify auto-backups is current."
Aside from the verification method, you have a few more options to pick when archiving data with GRAX:
Archive blocking children: this tells GRAX to delete child records that restrict deletes on their parent, like cases under an account.
Without this option you'll see
DELETE_FAILEDerrors for these records.
Additionally, in the Settings page there are global settings that apply to every archive:
Ignore objects: This holds a list of objects that GRAX skips, both while archiving and restoring data.
For archives, this ensures GRAX does not delete nor try to track deletion data for records of these given objects.
See archive troubleshooting for common errors and workarounds
Updated about 1 month ago