SFDX Quick Tip: Pulling source from a Sandbox into an SFDX project.

  1. Create an unmanaged package with everything you want to move over.
  2. Convert the unmanaged package with the SFDX CLI
  3. Push to a Scratch Org

Create the unmanaged package

Setup > Quick Find > "Package" > Create > Packages

Image for post
Create the Package

Next Select the files you want:

Image for post
Select the files you want

Retrieve the package with the CLI:

sfdx force:mdapi:retrieve -s -r {{pathToCreatePackageFile}} -u {{sandboxUsername}} -p {{packageName}}


mkdir package

sfdx force:mdapi:retrieve -s -r package/ -u [email protected] -p sfdxTransfer

You’ll then get a package in the directory you specified.

Convert the package to an SFDX project

With SFDX: sfdx force:mdapi:convert -r package/

This will create new files from the old package data.

Push to a Scratch Org

And last step is to push to a scratch org.

sfdx force:source:push will push to your default scratch org.

You will likely get an error or two, just read through and resolve. For example if you’re missing a field on an object you will have to create that in your scratch org. Use sfdx force:org:open to open your scratch org and sfdx force:source:pull to pull changes that you make.

Source: https://medium.com/eigen-x/sfdx-quick-tip-pulling-source-from-a-sandbox-into-an-sfdx-project-2361835d9f98