How do I generate a package.xml of all the metadata (fields,permissions,profiles users etc') of Account and Case objects from Production/Sandbox ?

My goal is to push it to a scratch org using sfdx.

I tried generating it from here https://packagebuilder.herokuapp.com but the service is currently down, also tried to use Workbench to export the Account metadata using the Rest Explorer (/services/data/v45.0/sobjects/account/describe) but I'm not sure how to combine it with the case object.

Can someone point me to a tutorial? I don't need it to be done programmatically.

  • Check again, I see that package builder in heroku working.
    – Adamo
    Jun 26, 2019 at 12:09

2 Answers 2


You can retrieve DX-compatible formatted source using DX:

sfdx force:source:retrieve -u prod-login -m "CustomObject:Account,CustomObject:Case,Profile"

This should retrieve all the metadata you're asking for without the need for a package.xml, which you can then immediately turn around and push:

sfdx force:source:push -u scratch-org-login

You'll need to be in a project folder for this to work.

The full flow from start to finish would look like this:

cd ~/workspace
sfdx force:project:create -n my-project-name
cd my-project-name
sfdx force:auth:web:login -a prod-login
sfdx force:config:set defaultdevhubusername=prod-login
sfdx force:org:create -f config/project-scratch-def.json -s
sfdx force:source:retrieve -u prod-login -m "CustomObject:Account,CustomObject:Case,Profile"
sfdx force:source:push
  • Thanks @sfdcfox, unfortunately when I try to push to the scratch org I get many errors, for example: "In field: queue - no Queue named Admin_Queue found (3371:16) on /Case/listViews/Admin_Queue_Case.listView-meta.xml" and also I get this one: "In field: recordType - no RecordType named Account.Customer found (413:29) on /profiles/Admin.profile-meta.xml" Maybe other objects need to be exported as well? please advise
    – Json
    Jun 28, 2019 at 8:57
  • @Json You might choose to remove some of that metadata (e.g. the listViews folder), or you can export additional stuff. It really depends on your intent. The object metadata can refer to lots of other dependencies, such as flexipages, Visualforce pages, other objects, etc.
    – sfdcfox
    Jun 28, 2019 at 13:22
  • According to salesforce.stackexchange.com/questions/261406/… I guess I'll have to wait for Shape Orgs GA
    – Json
    Jun 28, 2019 at 15:40

Usual disclaimer: I work at Gearset.

You can use Gearset's free trial to do this in a couple of minutes. Just log in and create a comparison between the org in question and a scratch org, then you can either deploy those objects straight to the scratch org, or you can download the zip package of the deployment that Gearset builds, which includes the metadata for the items you want to deploy and the package.xml we generate. Hope this doesn't come across as spammy - the free trial is all you need to get the package.xml you're after, and you don't need payment information or to install any packages or anything like that.

  • 3
    +1 As long as the answer is a potentially viable solution, and you disclose your affiliations, there's nothing wrong with answers like this. We wouldn't consider it to be spam in this case.
    – sfdcfox
    Jun 26, 2019 at 12:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .