Basic examples.


Table of Contents



Example 1. Very basic example for handling circular references.

The one of the main advantages of SFDMU, as it allows us to migrate complex data models with circular references without losing any data.

Here is a simple example of how SFDMU can handle circular references between migrated objects.

Suppose we have two objects, ObjectA and ObjectB, and each object has a lookup field that references the other object. This creates a circular reference between the two objects.

We can Insert records of both objects and maintain the circular reference between them by using the following configuration:

{
    "objects": [
        {
            "query": "SELECT Id, ObjectB__c FROM ObjectA__c",
            "operation": "Insert"
        },
        {
            "query": "SELECT Id, ObjectA__c FROM ObjectB__c",
            "operation": "Insert"
        }
    ],
    "excludeIdsFromCSVFiles": true,
    "promptOnMissingParentObjects": false
}
Notes:
  • Here, in this configuration, the SFDMU will first insert records of ObjectA__c. As a result, it can't populate values for the lookup field ObjectB__c since the records of ObjectB__c are not yet inserted in the target and there are no target Id values to populate.

    This can cause the plugin to generate a warning like: {ObjectA__c} 2 missing parent lookup records were found. See MissingParentRecordsReport.csv file for the details.

    In our case, you can disregard this message because the plugin will complete the missing lookups of ObjectA__c in a further step, after the ObjectB__c records already exist in the target.

    To prevent the execution from stopping and to avoid prompting the user whether they want to continue execution even with missing lookup values, set "promptOnMissingParentObjects": false.

  • Since the operation type is Insert, there is no need to define the externalId property as "Id" as it is automatically set by the Plugin at runtime.

Below you can find an example CSV file that can be used as a source for this configuration. You can use this export.json to transfer records from org to org, as well as from a CSV file to org:

ObjectA.csv

Id,ObjectB__c
a1,b1
a2,b2

ObjectB.csv

Id,ObjectA__c
b1,a1
b2,a2
Notes:
  • It's recommended to set "excludeIdsFromCSVFiles": true to tell SFDMU to treat the CSV files as raw data without the external Id columns such as ObjectB__r.Id. This is useful when you have to load CSV files with missing record Id or external Id values.

References:

Full export.json format

Last updated on 17th May 2023