[SalesForce] Automate master data loading after sandbox refresh

Test.loadData is used to load CSVs into an object during Test Class execution.
This test data exists only in the eyes of the test class.

In order to load master data using Apex after a refresh, is there a Test.loadData equivalent to load CSVs as real, permanent, data?

Best Answer

Use a sandbox "post copy" script, available since Spring'16.

Questions with this tag: .

Of course this will limit you to 10K rows created so if you need a complex structure - use this to kick off a batch job / series of @futures? Make a callout to other org from which you'll pull data... That kind of stuff.

I don't think there's easy way to automatically parse CSVs outside of unit tests, you'll need some custom code for that. But maybe you could store your sample data as JSON objects in static resource? Could be very handy & easy to load as long as you have some external id fields...

P.S. You do remember that this is a problem only in Developer (Pro) sandboxes? Partial Copy has built-in option to pull some slices of data during the refresh.

Related Topic