Newer Version Available

This content describes an older version of this product. View Latest

Retrieve Unpackaged Source Defined in a package.xml File

If you already have a package.xml file, you can retrieve it, unzip it in your local project, and convert it to source format. You can do all these tasks from the CLI. The package.xml file defines the source you want to retrieve.

But what if you don’t have a package.xml file already created? See Sample package.xml Manifest Files in the Metadata API Developer Guide.

If you already have the source in metadata format, you can skip these steps and go directly to converting it to source format.

Note

  1. In the project, create a folder to store what’s retrieved from your org, for example, mdapipkg.
  2. Retrieve the metadata.
    1sfdx force:mdapi:retrieve -r ./mdapipkg -u <username> -k ./package.xml
    The username can be the scratch org username or an alias. The -k parameter indicates the path to the package.xml file, which is the unpackaged manifest of components to retrieve.
  3. Check the status of the retrieve.
    When you run force:mdapi:retrieve, the job ID, target username, and retrieve directory are stored, so you don’t have to specify these required parameters to check the status. These stored values are overwritten when you run the force:mdapi:retrieve again.
    1sfdx force:mdapi:retrieve:report
    If you want to check the status of a different retrieve operation, specify the retrieve directory and job ID on the command line, which overrides any stored values.
  4. Unzip the zip file.
  5. (Optional) Delete the zip file.

After you retrieve the source and unzip it, you no longer need the zip file, so you can delete it.

After you finish, convert from metadata format to source format.