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

I'm trying to convert some code I'm writing in my sandbox into an SFDX project. The one complication is that my code references custom fields and objects that are part of a managed package.

Per the SFDX docs, I created an unmanaged package in the package manager in my sandbox, and added my apex class. All the referenced fields and objects were automatically pulled in as components as well:

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'):

This naturally follows through to the next step, when I convert the retrieved package with sfdx force:mdapi:convert to my SFDX project. Finally, when I try to push my SFDX package to a new scratch org, I get the following errors:

I'm not sure why there's an error about Entity 'LLC_BI__Loan__c' not found, since that's the one object that was retrieved. But my concern is mainly with not being able to pull the full set of components I need to make an SFDX project, using the method SF themselves prescribe here: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_retrieve_unman_pack.htm

• Not sure why this is not working but to get it working, either using ant migration tool or IDE like eclipse/mavensmate you can pull down the missing meta and combine with what you have currently. – Ranga Jun 28 '18 at 16:41

You can :

• 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

• Appreciate the workaround suggestion, and your plug of your plug-in ;). So it seems like this is just a bug of some kind on Salesforce's end, guess I should log a support case. – smohyee Jun 28 '18 at 19:27

I logged a case with Salesforce, here's the response I got:

Thank you for contacting Salesforce Technical Support.

If I'm not mistaken, you are using the Packaging 2 to manage your packages. Upon consulting with our experts, Packaging 2 is currently on the beta stage, which is a preview and isn't part of the “Services” under your master subscription agreement with Salesforce. This feature is currently not for production use, but for evaluation purposes only.

To give more insight regarding your concerns, provide feedback and/or suggestions for Packaging 2, you can post on the following Chatter group.

Packaging 2 Beta Trailblazer Community https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F93A000000Lg5U

Here is the documentation containing the information I've provided above:

Unlocked Packages and Second-Generation Managed Packages https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_dev2gp.htm

We sincerely apologize for this inconvenience. For now, I will be closing this case from our end, as this is currently out of scope for Technical support. Rest assured, the Chatter group is monitored by members of our Product team and your suggestions and feedbacks will be vital in helping improve and implement this feature in Salesforce.