8

We have a partial copy sandbox that we're using for development and testing. This is really helpful as some of our applications internally store Salesforce id's.

However, there is a limitation with the partial copy as it only brings in 10,000 records per object from the production environment. Unfortunately some of the id's we internally store are not being brought down into our partial copy which causes errors. The 10,000 records that it did copy over aren't needed; I realistically only need 1 or 2.

Is there any way I can achieve copying over a specific record from the production environment?

  • I think the answer is OOB no; but you might consider if possible using custom metadata types to store config data that will be copied from prod to sandbox – cropredy Jun 17 '16 at 22:05
  • @cropredy Could you elaborate on what you mean? I've been using Salesforce for a number of years, but I've never used "custom metadata" types. Would this allow me to somehow copy select data into my sandbox? – Justin Helgerson Jun 17 '16 at 23:06
  • no, just that if you only care about a handful of sobjects, it struck me that they might be serving as "config data" and rather than trying to get the specific rows, redesign the application to use custom metadata types – cropredy Jun 17 '16 at 23:47
  • It would be nice if the sandbox templates let us choose record types to copy. – martin Feb 15 '17 at 8:35
  • @Justin Helgerson, remember to accept an answer (ifany of them were useful). thanks! – glls Aug 14 '18 at 4:16
4

There are no guarantees of what records are copied to a partial sandbox. You get 10,000 random records of each object included in your template. There's not even a guarantee that you'll get all child records with any given parent record if they're related via Lookup, so you're almost guaranteed to get orphaned records. Salesforce makes ZERO promises about what records are copied. The only way to ensure that records are copied is to have fewer than 10k records for every object... and that's just impractical for most customers!

If you want specific records, you'll need a full copy sandbox.

I am curious, though, why you need IDs to match Production. Are you doing queries with hard-coded IDs? That's not a best-practice and should be avoided.

  • 2
    We don't have Ids hard-coded into our code, but they are being used to reference Salesforce records from external systems. When we generate test environments for the other systems, the production Ids are copied over and are referencing records that don't exist in our partial copy sandbox. I suppose we could mirror all Ids into custom external Id fields and use those Ids for all callouts to Salesforce, but I imagine the official best-practice would be to purchase a full-copy sandbox. – martin Feb 14 '18 at 1:21
3
+50

From the Trailhead on Application Lifecycle Management in regards to Partial Sandbox copies:

You can choose the objects, but not the records to pull.

If you absolutely need x number of records in your partial sandbox, an Option could be to use the Data Import Wizard or the Data Loader:

The data import wizard is optimal for loading up to 50k records while the Data Loader 50k+ to 5 million, both can be CSV based, making them easy to use.

Data Loader reads, extracts, and loads data from comma-separated values (CSV) files or from a database connection. When exporting data, it outputs CSV files.

the import data wizard is pretty straightforward:

enter image description here

and plenty of tutorials and documentation are available for both options.

  • Thanks for the answer. I do need the records to have the same Id as in production though, so the data loader and data import wizard won't work for my purposes. Even if I can't explicitly choose which records get copied, it would be nice to have some insight on how the records are selected so that I can at least give myself a fairly good chance of getting a few of the ~10% of the records I'm interested in testing. – martin Feb 7 '18 at 4:44
  • in that case, i guess your only bet is the full sandbox =( – glls Feb 7 '18 at 4:52
  • Maybe so. I'll give it a week though and see if anyone else here comes up with something. – martin Feb 7 '18 at 5:08
  • 1
    Even if you do have a full copy sandbox with all data you are not provided a guarantee that the IDs for a record will be the same between prod and sandbox. If your code relies on hardcoded IDs you should rewrite your code to be more flexible. – JaredT Feb 8 '18 at 20:54
1

The only way I know is to use a paid app like SFxOrgData or Prodly Moover. These apps can copy data sets from one instance to another and maintain the relationships. You can specify query conditions for some or all objects in the copy.

To use with a partial copy sandbox, you want the sandbox to start empty, so you would set up the sandbox template to include only one object, and that object has no records. Then you can use the app to copy the data you want.

  • 3
    How are record id's preserved? – Justin Helgerson Feb 8 '18 at 23:12
  • Both apps use the new IDs created in the target instance but they maintain the record relationships across the new IDs. SFxOrgData has to create a "old ID" field in each object of the target instance in order to do this. I don't think Prodly Moover needs to create these old ID fields because I think it pulls all the data into an external system and does a lot of processing there. – David Cheng Feb 9 '18 at 2:25
0

I ran another refresh of my partial copy sandbox, and again, it missed all of the records I was interested in testing.

Between the refreshes, 7639 of the records were the same, and 2362 of the records were new (the second refresh had 10001 records). There seems to be a bit of a stochastic component here, but when a group of ~9% of the total records is completely missed twice, I feel like whatever selection algorithm Salesforce is using is working against me.

Since these contacts are coming from a newer b2c line of business, my current theories are that either these records were not selected because:

  1. they are newer, or because
  2. they are all the only contact on their account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.