Retrieve Approval Processes using package.xml

Find how to retrieve Approval Processes using manifest/package.xml

Summery:

  1. Retrieve Single Approval Process
  2. Retrieve Multiple Approval Processes
  3. Retrieve All Approval Processes
  4. Fetch Approval Processes using SFDX command
Retrieve Approval Processes using package.xml file

Retrieve Single Approval Process

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <name>ApprovalProcess</name>
        <members>Account.Approve_30_Discount</members>
    </types>
    <version>62.0</version>
</Package>

Retrieve Multiple Approval Processes

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <name>ApprovalProcess</name>
        <members>Account.Approve_30_Discount</members>
        <members>Case.Close_Case</members>
    </types>
    <version>62.0</version>
</Package>

Retrieve All Approval Processes

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <name>ApprovalProcess</name>
        <members>*</members>
    </types>
    <version>62.0</version>
</Package>

What is ApprovalProcess in Salesforce?

An approval process defines the steps, approvers and actions for approving a record. Retrieving it lets you review the process outside the org and deploy it to another one.

Steps to retrieve it in VS Code

  1. Open your Salesforce DX project in VS Code and authorize your org with SFDX: Authorize an Org.
  2. Open manifest/package.xml, or create the file, and paste the XML shown above.
  3. Right-click package.xml and choose SFDX: Retrieve Source in Manifest from Org.
  4. When the command finishes, open the folder force-app/main/default/approvalProcesses to see the retrieved files.

Each member is ObjectName.ProcessUniqueName, such as Account.Approve_30_Discount. Use the unique name, not the display label.

Retrieve it with the Salesforce CLI

If you prefer the terminal, run one of these commands from your project folder:

sf project retrieve start --manifest manifest/package.xml
sf project retrieve start --metadata ApprovalProcess:Account.Approve_30_Discount

Where the files are saved

After a successful retrieve, the files are placed inside your project, for example in force-app/main/default/approvalProcesses/Account.Approve_30_Discount.approvalProcess-meta.xml.

Common problems and fixes

  • Entity of type ApprovalProcess cannot be found: check the spelling and the API name of the member, and make sure you are authorized to the correct org.
  • Nothing was retrieved: run sf org list to confirm the default org, and check that the component actually exists there.
  • API version: the examples use version 62.0. You can use a higher version if your org supports it.

FAQ

Where do I find the unique name of an approval process?
In Setup, open Approval Processes, choose the object, and read the Unique Name of the process.

Does a retrieved approval process include its email templates?
No. Related items such as email templates and workflow actions are separate metadata, so retrieve them too if you plan to deploy.

Leave a Reply