How to extract custom object meta-data into my DX project since sfdx force:source:status does not recognise the imported custom object via mdapi?

The reason to do this is to decouple my DX project from sandbox


  1. I have a very simple custom object with all default fields in sandbox.
  2. I retrieved this custom object metadata from sandbox by sfdx force:mdapi:retrieve
  3. I imported the metadata into a fresh new scratch org by sfdx force:mdapi:deploy
  4. I validate that the custom object with all its fields is visible in scratch org
  5. I run sfdx force:source:status, it doesn't notice this change in the corresponding scratch org

Expected result

sfdx force:source:status should have shown the diff and I would be able to pull the changes down to the local project.

  • This sounds like a commonplace problem, nobody has a clue or nobody had this issue at all...?
    – Xi Xiao
    Mar 29, 2018 at 20:39

1 Answer 1


I figured out that I need to convert the extracted meta-data from mdapi and convert into DX format in my DX project. Scratch org will not know the difference if I directly push these meta-data via mdapi into scratch org.


assume a package.xml containing list of meta-data is in place, the goal is to retrieve meta-data from sandbox and conver to a DX format so we can save these metadata to git as well as push into scratch org

sfdx force:mdapi:retrieve -r retrieveCodeoutput -k package.xml -u sandbox1

unzip retrieveCodeoutput/unpackaged.zip

then move the unpacked folder to a DX project root path

sfdx force:mdapi:convert --rootdir unpackaged/

above command will convert metadata info and save to current DX project


  • 1
    I tried this with an existing sandbox, but when deploying to a scratch org, all I got was the usual long list of errors (Invalid Type, Variable does not exist etc.)
    – Hans
    Dec 19, 2019 at 12:25

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.