I am trying to automate the test data migration in all my sandbox, I tried doing the data migration in more then 5 objects in one sandbox and that worked perfectly. But now, I want to automate this process, so that I don't have to load the data by hitting all the commands, so I am looking for some scripting kind of process, using which all my commands will run as they are in the script I just have to run the script once and the data will load in all the object in one sandbox.

Thanks in advance.


Using Salesforce DX, you can simply write a script for your OS.

In Windows and Linux, you just write the code you want in a plain text file:

sfdx force:data:import ...
sfdx force:data:import ...
sfdx force:data:import ...

In Windows, save the file ending in ".bat". In your command prompt, you can then run your script:

C:\Users\myname\workspace\project> setup-test-data.bat

In Linux, you set the executable bit on the file, then you run it like a script:

~/workspace/project $ chmod +x setup-test-data
~/workspace/project $ . setup-test-data

It is not very clear what your current process is which you are trying to replicate with SFDX, so I am going to make some assumptions.

It sounds like you have 5 existing scripts that you run after a Sandbox refresh, that populate various SObject data in said Sandbox. With SFDX you can use the data:tree framework to run commands against the SObject Tree API to pull data from an existing org and import it into a Sandbox or ScratchOrg:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.