How to prevent resetting checkboxes using SFDMU with multiselect keyword?


Question:

In SFDMU, I am using the multiselect keyword in my export.json for updating accounts, but the checkbox field (TEST_CHK__c) is being reset because it is not included in the source Account.csv file. How can I use the same CSV file with the multiselect keyword and still prevent the checkbox from resetting?

{
    "objects": [
        {
            "query": "SELECT all FROM Account",
            "operation": "Update",
            "externalId": "Name"
        }
    ]
}

And my Account.csv:

Id,AccountNumber,Name
0018d00000N237jAAB,1234567890,ACC_10000

Answer:

To prevent the checkbox field from being reset when using SFDMU with the multiselect keyword, you can utilize the excludedFields property or apply values mapping. These methods adjust how fields are handled during the update operation:

  1. Using Multiselect Keywords and Excluding Unwanted Fields: You can define the excludedFields property in your export.json to explicitly exclude checkbox fields from being updated. This ensures that these fields are not touched during the update process, thus preventing them from being reset:

    {
        "objects": [
            {
                "query": "SELECT all FROM Account",
                "operation": "Update",
                "externalId": "Name",
                "excludedFields": ["TEST_CHK__c"]
            }
        ]
    }
    

    This configuration excludes the TEST_CHK__c field from the update operation, leaving its value unchanged in the target org.

  2. Values Mapping with RegExp and Value Evaluation: Using values mapping, you can configure SFDMU to update the target with the source value only when the raw value is explicitly set. If the source value is empty, it remains unchanged. This approach uses a regular expression to match and evaluate field values:

    Here’s an example for ValuesMapping.csv:

    ObjectName FieldName RawValue Value
    Account TEST_CHK__c /(.+)/ eval('RAW_VALUE')

    This setup ensures that TEST_CHK__c is only updated if a value is explicitly provided in the CSV file, otherwise it retains its existing value in the target org.

Last updated on 20th Apr 2024