DeleteSource operation.

This feature allows you to delete object's records from the Source org, which are a final result of selection based on the whole export.json configuration, considering the relationships between objects.

Feature overview.

The normal behavior of the Delete operation is to delete records from the Target org, based on the supplied query string or using the special deleteQuery property (see: Full export.json format). This could be a satisfies solution, if you you exactly know which records you want to delete and can write a correct SOQL query to select only these records.

But in real situation, sometimes you can't directly select the desired records using SOQL queries, for example, when you have a complicated object model with a lot of related objects, e.g. you have to delete only those Contacts, which are related to some Accounts, which Accounts are related to another Test__c object.

As the solution we have introduced the DeleteSource operation.

This operaiton is useful if you don't have two (Source and Target) orgs and just want to delete the selected complex hierarchical data from one org.

Generally it acts similar to the Delete operation but it removes the SOURCE (instead of target when Delete operation is used !) records of this objects after all records for ALL OBJECTS IN THE CONFIGURATION was already retrieved from the Source org and all relaitonships between objects are already processed.

Example of DeleteSource configuration.

  "objects": [
            "operation": "Readonly",
            "externalId": "Name",
            "master": true,
            "query": "SELECT Id FROM Account WHERE Name LIKE 'Test%'"
            "operation": "DeleteSource",
            "master": false,
            "query": "SELECT Id, Account__c FROM TestObject__c"

This configuration will delete only those TestObject__c records which are related to the selected Accounts.


  • When using the DeleteSource, it's enough to define only the --sourceusername flag.
  • You can't use csvfile as the deletion source with the DeleteSource opetation.
  • You can also use mixed operations, i.e. to set the DeleteSource just for one object and for others you can set different operation, i.e. Upsert. In this case add --targetusername in your CLI command.

Below is the basic example of SFDX-CLI command to run a deletion from the source org:

 sfdx sfdmu:run --sourceusername
Last updated on 13th Nov 2023