How to empty all string fields of the sObject?

Question.


I want to clear all textual fields of the Account by settings their value to null. The problem is, that I don't know what fields of the string type are there, so can't list hem in the query string.

Can I do that with the SFDMU ?

Answer.


Yes. You can use the type_string multiselect keyword + the anonymizing feature to reset the string fields.

Run the job in the one-directional mode.

Below is the basic export.json configuration, which can help to achieve the challenge:

{

    "objects": [
        {
            "operation": "Update",
            "externalId": "Id",
            "query": "SELECT type_string FROM Account",
            "mockFields": [
                {
                    "name": "all",
                    "pattern": "c_set_value(null)",
                    "excludeNames": ["Name"]
                }
            ],
            "updateWithMockData": true
        }
    ]
}

It's recommended to exclude standard / unique fields like Name as well as other object fields that you don't want to affect with the job using the excludeNames array.

Run the job like that:

sfdx sfdmu:run -u my-target@org.com

See that you omit the --sourceusername flag, since the Source and the Target are the same org (one-directional mode).


See also:

Full export.json format

Fields multiselect

Data Anonymization

Running

Last updated on Sa Oct 2022