We recently integrated an incredibly powerful open-source tool into our workflow, significantly enhancing our Salesforce development process. This tool is the SFDX Data Move Utility (SFDMU), a plugin for the standard Salesforce CLI (SF CLI).
Key Features of SFDMU
SFDMU empowers administrators and developers with robust data management capabilities, including:
- Exporting records
- Performing CRUD operations (Insert, Upsert, Update, Delete)
- Transferring records between Salesforce orgs while maintaining relationship fields
- Custom field mappings for seamless data migration between objects
- Data anonymization for security and compliance
Installing and Uninstalling SFDMU
To install or update SFDMU, use the following commands:
# Uninstall the old version, if applicable
sf plugins uninstall sfdmu
# Install the latest version
sf plugins install sfdmu
Configuring SFDMU
All configurations for SFDMU are stored in an export.json
file. The example below retrieves all Account records where Type = Retail
and any related Contact records:
{
"objects": [
{
"operation": "EXPORT",
"externalId": "LastName",
"query": "SELECT FirstName, LastName, AccountId FROM Contact",
"master": false
},
{
"operation": "EXPORT",
"externalId": "Name",
"query": "SELECT Name, Phone FROM Account WHERE Type = 'Retail'"
}
]
}
To execute the export process, navigate to the directory containing export.json
and run the following command. This will generate Account.csv
and Contact.csv
files containing the retrieved data:
# Export data from a Salesforce org to CSV files
sf sfdmu run --sourceusername [email protected] --targetusername csvfile
You can then modify the CSV files as needed and import the updated data back into Salesforce:
# Import data from CSV files to a Salesforce org
sf sfdmu run --sourceusername csvfile --targetusername [email protected]
SFDMU for Data Migration Between Salesforce Orgs
One of the most valuable features of SFDMU is its ability to transfer data between Salesforce organizations.
While Salesforce provides the ability to create Partial and Full Sandboxes that automatically include production data, Developer Edition sandboxes do not. This limitation can be challenging for organizations with complex data models.
For example, several of our clients require specific records to exist before an Account can be created, as automation rules prevent record creation without the necessary dependencies.
SFDMU streamlines the setup of every developer sandbox by allowing us to execute a single command to populate the required data.
To perform a migration between Salesforce orgs, modify the export.json
configuration by changing the operation from EXPORT
to UPSERT
or INSERT
, then execute the following command:
# Migrate data from one Salesforce org to another
sf sfdmu run --sourceusername [email protected] --targetusername [email protected]
Conclusion
SFDMU is a powerful tool that simplifies Salesforce data operations, making it an essential part of our development workflow. Part 2 will explore some of SFDMU’s more advanced features!