Gearset has recently introduced a new workflow to allow you to restore deleted records and any related child records that were removed as a result of that deletion. The new workflow will allow you to build up a restore plan starting with a base object and then you can select the records of child objects (and grandchild / child-of-child objects) you want to restore.

A common example of this would be an Account record that was deleted. The cascading nature of the Salesforce's deletion logic means that all the Opportunities on the Account and the OpportunityLineItems (listed as Products on the Opportunity) will also be deleted. The new restore flow will allow you to restore all of these items in a single restoration deployment.

How to use the new workflow

The new workflow can be accessed through View changes via the restore button in the changes details page. This will only appear for records where you have deleted/changed records in this run.

Clicking the arrow next to Restore will allow you to select whether you want to Restore [Base object] with dependencies or Restore changed fields within [Base object]. See how to restore changed fields here.

Restoring objects with dependencies

Clicking this button will select this object as the Base object where we can build up a restoration plan. When you come into the Restore from [Base object] page, we will show the Base object along with the first level of child relationships.

If you expand the relationship it will then populate with the next level of relationships:

Note that by default we only show objects with non-zero counts of records. If you want to see the relationships where there are no unchanged records, you can click the Show unchanged records button:

As there can be many relationships which do not have any unchanged records, we hide these by default, but it can be useful to check to confirm that no related records were deleted along with the Base object records.

You are also able to filter on the Base object, by clicking the filter icon in the Total records to restore column:

This will bring up a similar filter dialog to those used in data deployments or browsing backed up records:

Once you apply this filter to the Base Object it will also update the record counts for the related child objects:

Once you have selected the records you want to include, you can create a restore plan by clicking the Preview restore button:

Disabling Validation rules, Triggers and Flows

If you have any active flows, triggers or validation rules on the objects to be restored, it is recommended you disable these before the deployment as these may cause Salesforce deployment errors. This can be done either manually in your Salesforce org, or through Gearset. To disable these through Gearset, click View and disable rules on the backup data summary page.

This will start a comparison for any validation rules and flows on these objects. Clicking Compare and deploy rules will open the comparison page. From here select the rules, triggers and flows you want disabled and then deploy your chosen items just like a normal metadata deployment. (Note: these will not include manage package metadata triggers or validation rules.)

Once you've finished your restoration, you can re-enable the rules, triggers and flows by rolling back the metadata deployment via the deployment history.

Finishing the restoration

Once the restoration plan is created, you will be brought to the backup data summary page, similar to what you would see on the final stage of a restore:

To view the records about to be deployed for an object, click on the name of the object being deployed (for example Account).

Click Deploy data to deploy to restore back to your org:

Your records should now have been restored to your org.


  • We do not support restoring children of the same object type: eg. Child Accounts, we are looking to add this functionality in at a later stage

Example: Restoring a deleted Account along with its Opportunities and OpportunityLineItems

We will now walk through an example of how you can restore a fairly simple deletion using this new workflow. The example we use is for the deleted records of some standard Salesforce objects: Account, Opportunity and OpportunityLineItem. Note: This workflow also works for most object and their child relationships, see below.

The relationship here is Account has child Opportunities; Opportunities have child OpportunityLineItems. Viewing this on the Schema builder in Salesforce (OpportunityLineItems are shown as Opportunity Products):

In a simpler form, where the arrows point from a parent record to a child record:

Here is an example in Salesforce:
We have an Account with two Opportunities on it:

One Opportunity has 3 OpportunityLineItems (shown as Products):

Another Opportunity has 4 OpportunityLineItems (shown as Products):

This Account then gets deleted. On the next data backup run, we see that we have the deleted Account along with its 2 Opportunities and 7 OpportunityLineItems. We select Restore with dependencies , using the deleted Account as the Base object (red box).

When we open the Restore from Account page, the Child relationships are populated. We can see the Account object has Opportunities as a child:

We then expand the Opportunities to get the OpportunityLineItems:

We then select the Account, Opportunity and OpportunityLineItems and click Preview restore to plan a restoration:

This will create a plan where we can deploy the data:

We then click Deploy data to restore the data:

Once it has completed we can view the restored records in Salesforce:

Restoring with a custom setup

Even though the example above is for standard Salesforce objects, you can restore in a similar way for many different setups. For example the same process could be used for an org with custom objects with child and grandchild relationships:

Future plans and feedback

We are always looking to improve the product and want to work on features that offer the most value to customers. If you have any feedback of how we can improve this workflow or new functionality we can add let us know through the in app chat. We look forward to hearing from you!

Did this answer your question?