Records to Restore Editor

The “Records to Restore” component of the “Restore Set Editor” determines which records will be restored to Salesforce.

Though there are a number of options they all share common properties:

  • Their purpose is to select a set of Salesforce record Ids to restore.
  • You can determine whether insert, update, or both types of restore operations are allowed.
  • The “Record Match Policy” determines how a match between a database record and an existing Salesforce record is performed — options include:
    • Salesforce Id — records match if they have the same unique Salesforce Id.
    • External Id — records match if they have the same value in the column marked as an external Id:
    • Multi-Column — records match if they have the same value(s) in one or more columns
  • The “Max # Per Update” option overrides the default number of records sent to Salesforce in a single batch.
  • The “# Salesforce Writers” option overrides the number of Salesforce writer threads to use.
    • The global is almost always the best value unless a table has functional aggregate columns — in this case a value of 1 is usually best.

Restore All Records

The “All” option will restore all records in the CopyStorm backup to the Salesforce database:

Restore Filtered Records

The “Filter” option will restore records that match a drag-and-drop set of criteria in the CopyStorm backup to the Salesforce database. To use a record filter to select records in CopyStorm, please see the page here: Limiting Records To Restore With a Record Filter.

Restore Using an Id File

The “Id File” option will read Salesforce record Ids from a supplied text file and restore only the records referenced in the file.

Note: The Ids are the full 18 character Salesforce record Ids.

Restore Using an Id List

The “Id List” option will restore Salesforce records based on record Ids copied into a text box. Ids should be delimited using a space or a comma.

There is no practical limit to the number of Ids you can paste into the box.

Note: The Ids are the full 18 character Salesforce record Ids.

Restore Random Records

The “Random” option will restore a random number of Salesforce records, optionally limited to a set of Ids provided based on a SQL statement or record filter.

If a value is provided for the “Seed” parameter the same records will be restored each time.

  • This can be useful for restoring a development sandbox to exactly the same state every time.
  • The “Seed” parameter can be any positive non-zero number from 1 to 9 digits in length.

To restrict records using a record filter, select “Filter” from the “Constraint Type” dropdown and:

  1. Click on “Click Here To Edit”.
  2. See this page for more information on configuring a record filter in CopyStorm/Restore: Limiting Records To Restore With a Record Filter.

To restrict records using a SQL statement, select “SQL” from the “Constraint Type” dropdown and:

  • Example 1: Limit the selection to accounts with a shipping country of “Elbonia”:
    • SELECT id FROM Account WHERE ShippingCountry=’Elbonia’
  • Example 2: Limit accounts to those with Opportunities having a value greater than $1,000,000:
    • SELECT DISTINCT accountId FROM Opportunity WHERE amount > 1000000

Restore Referenced Records

The “Referenced” option will only restore a record if it is referenced by another Salesforce record being restored. This option is selected automatically as a side-effect of including a related list for another table.

For example, if a user selects random Account records to restore and selects the Opportunity related list, a rule to restore referenced Opportunities will automatically be created.

When creating test data in a sandbox restoring referenced records may cause more data than desired to be restored. For example, if restoring all Cases referenced by restored Accounts, much more data than needed may be restored.

There are three parameters which can control the number of referenced records to be restored:

  • The “Max # Per Parent” is the maximum number of child records that should be restored for each parent.
    • For example, if this number is 5 for restoring Cases, then no more than 5 Cases will be restored for each unique Account.
  • The “Max # Total” is the maximum number of child records that should be restored for all parents.
    • For example, if this number is 200 for restoring Cases, then no more than 200 Cases will be restored in total.
  • The “Constraint Type” allows the restored records to be limited to referenced records that match a specific set of criteria.
    • Select “Filter” to edit a drag-and-drop record filter that will be used to limit the related objects being restored.
    • Select “SQL” to provide a SQL fragment that will be added to the WHERE cause of the SQL used to look for related objects.
      • For example, if this is set to “closeDate >= ‘2015-01-01′” for Opportunity then only Opportunities in 2015 or later will be selected.
      • Any column in the CopyStorm backup database can be used to form this constraint.
      • The only restriction for this parameter is that it must be valid SQL when appended to a statement like:
        • SELECT id FROM Opportunity WHERE (…) AND (<>)

Note that the actual number of referenced records restored may be slightly larger than the specified constraint. This is because records are also restored because of a reference field constraint, but the number of additional records restored is typically small.

Restore Records by SQL

The “SQL” option will restore all records whose id matches the value returned by a user supplied SQL statement.

For example,

  • To select Contacts in Ohio:
    • SELECT id FROM Contact WHERE MailingState=’OH’
  • To select Contacts with open support cases:
    • SELECT contactId FROM Case2 WHERE isClosed=0