Advanced examples.


Table of Contents



Example 1. Migration of Accounts and Contacts with AccountContactRelations.

{
     "objects": [
         {
              "query": "SELECT Id, Name FROM Contact",
              "operation": "Upsert",
              "externalId": "Name",
              "master": false
         },
         {
              "query": "SELECT id, Name FROM Account",
              "operation": "Upsert",
              "externalId": "Name"
         },
         {
              "query": "SELECT Id, AccountId, ContactId FROM AccountContactRelation",
              "operation": "Upsert",
              "externalId": "Account.Name;Contact.Name",
              "master": false
         }
     ]
}

Example 2. Migration of FeedItems and FeedComments.

{
  "objects": [
    {
        "operation": "Readonly",
        "query": "SELECT Id FROM Account WHERE Name = 'ACC_10000'",
        "externalId": "Name"			
    },
    {
      "query": "SELECT CommentCount, IsRichText, LikeCount, ParentId$Account, Revision, Status, Title, Type, Body, LinkUrl FROM FeedItem WHERE Type IN ('TextPost', 'LinkPost') AND (Parent.Type = 'Account')",
      "operation": "Insert"
    },
    {
      "query": "SELECT CommentType, FeedItemId, IsRichText, Revision, Status, ThreadChildrenCount, ThreadLastUpdatedDate, ThreadLevel, CommentBody FROM FeedComment ",
      "operation": "Insert",
      "master": "false"
    }
  ]
}
Notes:
  • This example will not transfer FeedItems of "ContentPost" type along with their binary data.

    For that please refer to File data transfer examples

Example 3. Locate and delete the same target records which are already deleted in the source.

{ 
  "objects": [
        
        {
            "query": "SELECT Id FROM Opportunity WHERE Name ='TestOpportunity' AND isDeleted = true",
            "operation": "DeleteHierarchy",
            "externalId": "Name",
            "useQueryAll": true
        }
    ]
}

Example 4. Inserting Variation Attributes and Product Variations.

{
    "objects": [
        {
            "query": "SELECT Name, Type, IsActive, StockKeepingUnit, ProductClass, ProductCode FROM Product2 WHERE IsActive = true AND ProductClass IN ('Variation', 'VariationParent')",
            "operation": "Insert",
            "master": false
        },
        {
            "query": "SELECT MasterLabel FROM ProductAttributeSet",
            "externalId": "DeveloperName",
            "operation": "Readonly"
        },
        {
            "query": "SELECT Campus__c, Sequence, ProductId, VariantParentId FROM ProductAttribute",
            "operation": "Insert"
        },
        {
            "query": "SELECT ProductAttributeSetId, ProductId FROM ProductAttributeSetProduct",
            "operation": "Insert"
        }
    ],
    "excludeIdsFromCSVFiles": true
}

Below is the example set of CSV files which can be imported using this configuration:

Product2.csv

Name Type IsActive StockKeepingUnit ProductClass ProductCode
Bachelor i Finance Base TRUE VariationParent BACH-F
Bachelor i Finance Oslo TRUE BACH-F-1 Variation
Bachelor i Finance Jerusalem TRUE BACH-F-2 Variation

ProductAttribute.csv

Campus__c Sequence Name Product.Name VariantParent.Name
Oslo 1 PA-00000001 Bachelor i Finance Oslo Bachelor i Finance
Jerusalem 2 PA-00000002 Bachelor i Finance Jerusalem Bachelor i Finance

ProductAttributeSet.csv

MasterLabel DeveloperName
Campus Campus_1

ProductAttributeSetProduct.csv

Name ProductAttributeSet.DeveloperName Product.Name
PASP-00000002 Campus_1 Bachelor i Finance
Notes.
  • In this example Product object has Variation Attribute "Campus__c".

  • ProductAttributeSet object is Readonly. It can't be updated by the SFDMU and should be preconfigured using Commerce Setup UI.

  • For inserts we use Record Id field as an External Id.

  • In CSV files we omit Record IDs and lookup IDs, but we need to provide external id values for all objects to let SFDMU know how to link target objects.

Example 5. Upserting Variation Attributes and Product Variations.

The below configuration can be used to Upsert Product Attribute Sets and related Variation/VariationParent products. It should work both in org2org and csv2org migration directions:

{
    "objects": [
        {
            "query": "SELECT Name, Type, IsActive, StockKeepingUnit, ProductClass, ProductCode FROM Product2 WHERE IsActive = true AND ProductClass IN ('Variation', 'VariationParent')",
            "externalId": "ProductCode;StockKeepingUnit",
            "operation": "Upsert",
            "master": false
        },
        {
            "query": "SELECT MasterLabel FROM ProductAttributeSet",
            "externalId": "DeveloperName",
            "operation": "Readonly"
        },
        {
            "query": "SELECT Campus__c, Sequence, ProductId, VariantParentId FROM ProductAttribute",
            "externalId": "Product.StockKeepingUnit;VariantParent.ProductCode",
            "operation": "Upsert"
        },
        {
            "query": "SELECT ProductAttributeSetId, ProductId FROM ProductAttributeSetProduct",
            "externalId": "ProductAttributeSet.DeveloperName;Product.ProductCode",
            "operation": "Upsert"
        }
    ],
    "excludeIdsFromCSVFiles": true
}

Below is the example set of CSV files which can be imported using this configuration:

Product2.csv

Name Type IsActive StockKeepingUnit ProductClass ProductCode $$ProductCode$StockKeepingUnit
Bachelor i Finance Base TRUE VariationParent BACH-F BACH-F
Bachelor i Finance Oslo TRUE BACH-F-1 Variation BACH-F-1
Bachelor i Finance Jerusalem TRUE BACH-F-2 Variation BACH-F-2

ProductAttribute.csv

Campus__c Sequence $$Product.StockKeepingUnit$VariantParent.ProductCode Product.$$ProductCode$StockKeepingUnit VariantParent.$$ProductCode$StockKeepingUnit
Oslo 1 BACH-F-1;BACH-F BACH-F-1 BACH-F
Jerusalem 2 BACH-F-2;BACH-F BACH-F-2 BACH-F

ProductAttributeSet.csv

MasterLabel DeveloperName
Campus Campus_1

ProductAttributeSetProduct.csv

ProductAttributeSet.DeveloperName $$ProductAttributeSet.DeveloperName$Product.ProductCode Product.$$ProductCode$StockKeepingUnit
Campus_1 Campus_1;BACH-F BACH-F
Notes.
  • In this example Product object has Variation Attribute "Campus__c".

  • ProductAttributeSet object is Readonly. It can't be updated by the SFDMU and should be preconfigured using Commerce Setup UI.

  • For upserts we have to use the Composite Key Feature to guarantee uniqueness of keys for each object.

  • In CSV files we omit Record IDs and lookup IDs, but we need to provide external id values (they are composite keys) for all objects to let SFDMU know how to link target objects.

Last updated on 14th Apr 2024