+ Start a Discussion
Sam Mohyee 12Sam Mohyee 12 

sfdx force:mdapi:retrieve on unmanaged package doesn't retrieve all components in package

I'm trying to convert some code I'm writing in my sandbox into an SFDX project. 

Per the SFDX doc (here), I created an unmanaged package in the package manager in my sandbox, and added my apex class, which in turn pulled into the package all the fields and objects referenced by the class:
User-added image

Note that there are three custom objects from a managed package included there:

  • Loan
  • Deposit
  • Entity Involvement

However, when I look at the unzipped package retrieved via sfdx force:mdapi:retrieve, there appears to only be metadata for one of those objects, along with the standard account object (which we've relabeled 'Relationship'):

User-added image

Naturally, this produces an error when trying to convert to an SFDC project and deploy to a scratch org, since referenced metadata is missing. Note that all but the Account object are part of a managed package... but it's strange that one of the managed package objects was retrieved successfully, and the other two didn't. 

Is this a bug, or am I doing something wrong? And if it's a bug, how can I report it if our company's SF support level precludes any development-related cases?

NagendraNagendra (Salesforce Developers) 
Hi Sam,

Please find the solution suggested on stack exchange community for the same.
  • generate the package.xml of your whole sandbox using https://packagebuilder.herokuapp.com/
  • use force:mdapi:retrieve with the generated package.xml in a temp folder
  • copy paste the missing metadatas into your unmanaged package retrieve folder
Then, when you will need to deploy to another org, if you don't need to deploy the whole SFDX project in an org (Profiles etc ...) , but only the content of a package.xml file, you can use command sfdx essentials:filter-metadatas of sfdx plugin https://github.com/nvuillam/sfdx-essentials

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
Sam Mohyee 12Sam Mohyee 12
Hi Nagendra,

I posted that stack exhange post, and saw your response! The reason I'm posting it here as well is because this is a clearly an issue with SF's metadata api or SFDX's metadata retrieve command, and I'm trying to bring it to the attention of the SF dev team. Unfortunately, I can't log a case to report a bug on a developer topic, as that requires a paid support package.

Rather than be stuck with a workaround that takes extra time, I'd like to get this on the list of known issues so it has a chance of being resolved!