Retrieve Your Managed Package

In this exercise, you will…

  • Use force:mdapi:retrieve to get a local copy of the metadata from your packaging org

Use force:mdapi:retrieve to get a local copy of the metadata from your packaging org

Before you can use Salesforce DX to develop your app, you’ll need to retrieve your package’s metadata. The force:mdapi:retrieve command can help you do this.

Important: When you copy/paste the following command, remember to replace "My Managed Package" with the name (not the namespace, but the name) of your managed package. If you use the incorrect name, or make a mistake, the force:mdapi:retrieve command will not work as expected.

Execute this command:

sfdx force:mdapi:retrieve \
    -u PkgOrg \
    -p "My Managed Package" \
    -r mdapi-source \
    -w 10 \
    -s
Salesforce DX Command / Flags Description
force:mdapi:retrieve Uses Metadata API to retrieve a .zip of XML files that represent metadata from the targeted org.
-u (--targetusername) A username or alias for the target org. Overrides the default target org.
-p (--packagenames) A comma-separated list of package names to retrieve.
-r (--retrievetargetdir) The root of the directory structure where the retrieved .zip or metadata files are put.
-w (--wait) The number of minutes to wait for the command to complete.
-s (--singlepackage) Specifies whether only a single package is being retrieved (true) or more than one package (false).

While your package is being retrieved, your terminal should look something like this:

After your package is retrieved, VS Code should look something like this:

  1. The CLI will show a Result message giving you the status of the retrieval.
  2. A new file, unpackaged.zip will appear inside of a new directory, mdapi-source.

Updated: