Deployment B/W Different Salesforce Orgs Using Custom Metadata

Table of contents
- ๐ Detailed Steps to Move Salesforce Flow Using Salesforce CLI (SFDX)
- 1. Install Salesforce CLI (SFDX)
- 2. Set Up a Salesforce DX Project (Folder)
- 3. Authenticate (Log in) to the Source Org (where Flow is present)
- 4. Create a package.xml to tell Salesforce which Flow to download
- 5. Retrieve the Flow from the Source Org
- 6. Authenticate (Log in) to the Destination Org (where you want to deploy)
- 7. Deploy the Flow into the Destination Org
- 8. Validate in the Destination Org
- ๐ Important Points:
- ๐ฅ Summary of Commands
- โก Quick Summary
๐ Detailed Steps to Move Salesforce Flow Using Salesforce CLI (SFDX)
1. Install Salesforce CLI (SFDX)
First, you must have Salesforce CLI installed.
Download and install it from here: Salesforce CLI Download.
After installing, open your Terminal (Mac/Linux) or Command Prompt (Windows).
โ To verify installation, run:
sfdx --version
You should see a version number.
2. Set Up a Salesforce DX Project (Folder)
Now create a project to manage your Flow files.
sfdx force:project:create -n MoveFlowProject
cd MoveFlowProject
This creates a folder called MoveFlowProject
with the right structure.
Inside the folder, youโll see:
sfdx-project.json
force-app/main/default/
We will store the Flow here soon.
3. Authenticate (Log in) to the Source Org (where Flow is present)
Now connect your source org.
sfdx auth:web:login --setalias source-org
A browser window will open.
Login to your source org.
It saves this org connection with the alias
source-org
.
โ You can check your connected orgs by:
sfdx force:org:list
4. Create a package.xml
to tell Salesforce which Flow to download
Salesforce CLI needs to know what to retrieve.
Create a file called package.xml
inside a folder like /manifest/
.
Example package.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Your_Flow_API_Name</members>
<name>Flow</name>
</types>
<version>59.0</version> <!-- Use API version of your org, or latest -->
</Package>
Replace
Your_Flow_API_Name
with the API Name of your Flow (not label, API Name is likeOrder_Process_Flow
).Save it inside a folder, say
/manifest/package.xml
.
5. Retrieve the Flow from the Source Org
Now retrieve your Flow metadata.
sfdx force:mdapi:retrieve -r ./mdapioutput -u source-org -k manifest/package.xml
Meaning:
-r ./mdapioutput
โ save the output insidemdapioutput
folder.-u source-org
โ retrieve from source org.-k manifest/package.xml
โ use your package.xml to know what to pull.
โ
You will see a .zip
file downloaded into mdapioutput
.
Now unzip that .zip
inside your project to see the metadata.
6. Authenticate (Log in) to the Destination Org (where you want to deploy)
Now connect your destination org.
sfdx auth:web:login --setalias destination-org
A browser window opens.
Login to your destination org.
Saves the alias as
destination-org
.
7. Deploy the Flow into the Destination Org
Now push the Flow to destination org.
sfdx force:mdapi:deploy -d ./mdapioutput/unpacked_folder -u destination-org -w 10
-d
specifies where your retrieved metadata is.-u destination-org
tells it which org to deploy to.-w 10
tells Salesforce CLI to wait for 10 minutes (adjust if needed).
โ After successful deployment, your Flow is copied!
8. Validate in the Destination Org
Login to your destination org.
Go to Setup โ Flows.
You should see your Flow there!
๐ Important Points:
Step | Item |
You must have the Flowโs API Name | (e.g., DiscountApprovalFlow ) |
You must handle dependencies manually | (example: custom fields, objects, etc.) |
Use correct API version in package.xml | Example: 59.0 |
You may need to adjust settings if the Flow uses specific objects not existing in destination org. |
๐ฅ Summary of Commands
# Create Project
sfdx force:project:create -n MoveFlowProject
# Login to Source Org
sfdx auth:web:login --setalias source-org
# Retrieve Flow
sfdx force:mdapi:retrieve -r ./mdapioutput -u source-org -k manifest/package.xml
# Unzip and prepare
# Login to Destination Org
sfdx auth:web:login --setalias destination-org
# Deploy Flow
sfdx force:mdapi:deploy -d ./mdapioutput/unpacked_folder -u destination-org -w 10
โก Quick Summary
[Source Org] โ [Retrieve Flow to Local] โ [Login to Destination Org] โ [Deploy Flow]
Subscribe to my newsletter
Read articles from Pradhumn Sharma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Pradhumn Sharma
Pradhumn Sharma
As a Salesforce Technical Consultant, I'm like the trailblazer in a digital jungle, swinging from cloud to cloud to unlock the hidden treasures of data. I speak fluent Apex and dance through flows like nobody's business. If you're up for a wild Salesforce adventure, I'm your trusty guide. Let's journey through the clouds and make your business dreams take flight! ๐๐ป๐ #Salesforce When you need Salesforce superpowers, and I promise not to speak in too much technobabble...unless you ask! Let's connect and discover how I turn cloud chaos into customer-pleasing comedy. ๐คฉ If there is anything I can help with - Just ask! Trailblazer: https://trailblazer.me/id/pradhumnsharma