function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vitaly Gusakov 1Vitaly Gusakov 1 

Archive Records from Salesforce to Database

Please tell me how you can make an archiver of records and objects into an external database and then delete them from Salesforce? Let's say your task is to delete records from 5 objects whose creation date is less than 2019. How to think through the logic of collecting all child records and objects? How to avoid duplicates and intersections?
ankit bansalankit bansal
Hi Vitaly,
The best contentder to write a record archiver is to leverage the power of a scheduled batch job. A batch job can process upto 50 million records so it can handle large data volumes. It can be scheduled to run in off buiness hours say around 12:00am everyday , so it will pick up the records which were created before 2019 or suppose more that 2 years ago and push them to external system for archival and also delete them.
For catching duplicates I would suggest that you use salesforce external data source to connect to the archival system and then query it so that while creating new records in salesforce the archived data is take into consideration for duplicate calculation.
Here is a blog on how to use external data source-
https://salesforcelightningblog.wordpress.com/2018/03/28/external-data-sources-and-external-objects-in-salesforce/