Newer Version Available

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

Step 3: Retrieve Components with Metadata API

With Salesforce CLI, retrieve a file representation of the specified components in your package.xml manifest.

Two Options for Metadata API Retrieve

You can use one of two commands to retrieve metadata components.

  1. To retrieve the components specified in your package.xml manifest, issue a retrieve call using a Salesforce CLI command. On the command line, run this call with the appropriate file path:

    sf project retrieve start --manifest path/to/package.xml

    Metadata retrieve() is an asynchronous, file-based command. You can issue multiple retrieve or deploy requests that run on their own when resources are available.

    With this command, you send a request to retrieve all custom objects as specified in your package.xml manifest. Your requests are queued until our systems are ready to process your retrieve call. After your request is dequeued, your retrieve call is run. The client checks the status of the retrieve and notifies you when the call is complete. The call returns a file representation of the chosen components. When you use Salesforce CLI to issue a retrieve call, all these processes are automated.

    The project retrieve start command allows for source tracking. Source tracking includes information about which revision you’re working on and when the last changes were made, which makes source commands more developer-friendly. To use source tracking, ensure that it’s enabled in your org.

  2. Alternatively, run this command in your terminal:

    sf project retrieve start --manifest path/to/package.xml --target-metadata-dir path/to/retrieve/dir

    This command retrieves components in mdapi format rather than source format, and doesn’t allow for source tracking. In practice, admins use mdapi commands more often because the commands don’t include source tracking.