Delete by Hierarchy / DeleteHierarchy.

This feature allows you to delete the records from the Target environment, which were selected from the Target, based on the export.json object configuration and on the retrieved source data, considering the relationships between the objects


Feature overview.

It's very similar to the deleteFromSource feature.

This option features deletion the hierarchical Target data, based on the export.json and on the data, which was retrieved from the Source environment or csv file. It acts like the operation=Update, but it makes a deletion instead of update.

This feature can be very useful when, for example, you have a source csv file contains list of record Ids to be deleted from the target salesforce org. Of course, instead of csv any salesforce org can be used as a data source.

You can add to you export.json as many related objects a you want to delete them at once.

(Starting from the 4.2.1 ScriptObject.deleteByHierarchy was deprecated and replaced with the new operation=DeleteHierarchy, however the ScriptObject.deleteByHierarchy=true is still supported to allow the backward export.json format compatibility)

Example.

  "objects": [        
        {
            "operation": "Delete",
            "deleteByHierarchy": true,
            "externalId": "Id",
            "query": "SELECT Id FROM Account"
        }
    ],

OR (providing the same result) :

  "objects": [        
        {
            "operation": "DeleteHierarchy",
            "externalId": "Id",
            "query": "SELECT Id FROM Account"
        }
    ],

The configurations above can be utilized to delete the records from the test@testorg.com , using csv file as a data source.

Run the Plugin with the following command:

 sfdx sfdmu:run --sourceusername csvfile --targetusername test@testorg.com

See also:

Full export.json format.

Last updated on Tu May 2022