Retrieve all types of Metadata In Salesforce

Index:

  1. Apex Classes
  2. Triggers
  3. Flows
  4. Objects 
  5. Record Types
  6. Visualforce pages
  7. Lightning Web Components
  8. Aura Components 
  9. Salesforce Apps
  10. Lightning App Utility Bar
  11. Connected Apps
  12. Approval Processes
  13. Validations Rules
  14. Workflow Rules
  15. Workflow Field Update
  16. Process Builders
  17. Email Templates

Apex Classes

Package.xml
<types>
    <name>ApexClass</name>
    <members>AccountHandler</members>
    <members>CaseTriggerHandler</members>
</types>
SFDX Command
sfdx force:source:retrieve -m LightningComponentBundle:lookupComponent

Apex Triggers

Package.xml
<types>
    <name>ApexTrigger</name>
    <members>ContactTrigger</members>
    <members>StudentTrigger</members>
</types>
SFDX Command

Note: Following command will retrieve all apex triggers

Pro Tip: To retrieve Single Apex Trigger using SFDX, Create Package.xml file in manifest folder and run the following command

sfdx force:source:retrieve -p force-app/main/default/triggers

sf force:source:retrieve -p force-app/main/default/triggers

Salesforce Flows

Package.xml
<types>
    <name>FLow</name>
    <members>LWC_And_Flow_Demo</members>
</types>

Tip: How to retrieve specific version of flow?

<types>
    <name>FLow</name>
    <members>LWC_And_Flow_Demo-1</members>
    <members>LWC_And_Flow_Demo-9</members>
    <members>LWC_And_Flow_Demo-24</members>
</types>

Standard & Custom Objects

Package.xml
<types>
    <name>CustomObject</name>
    <members>Object_API_Name</members>
    <members>Account</members>
    <members>Case</members>
</types>

Record Types

Package.xml
<types>
    <name>RecordType</name>
    <members>Record_Type_Name</members>
</types>

Visualforce Pages

Package.xml
<types>
    <name>ApexPage</name>
    <members>CommunitiesLanding</members>
    <members>CommunitiesLogin</members>
</types>

Tip: How to retrieve all Visualforce pages?

<types>
    <name>ApexPage</name>
    <members>*</members>
</types>

LWC: Lightning Web Components

Package.xml
<types>
    <name>LightningComponentBundle</name>
    <members>lookupComponent</members>
</types>
SFDX Command
sfdx force:source:retrieve -m LightningComponentBundle:lookupComponent

Try the following command to retrieve all LWC using SFDX:

sfdx force:source:retrieve -p force-app/main/default/lwc

Tip: How to retrieve all lightning Web Components?

<types>
    <name>LightningComponentBundle</name>
    <members>*</members>
</types>

Aura Components

Package.xml
<types>
    <name>AuraDefinitionBundle</name>
    <members>customNavigationBar</members>
    <members>quickActionsManager</members>
</types>

Salesforce Apps

Below Syntax is used to Retrieve Standard and Custom Salesforce Lightning Apps.

Retrieve Standard Apps

<types>
    <name>CustomApplication</name>
    <members>Standard__LightningSales</members>
    <members>Standard__LightningBolt</members>
</types>

Retrieve Custom Apps

<types>
    <name>CustomApplication</name>
    <members>Application_DeveloperNmae</members>
</types>

Lightning App Utility Bar

Package.xml
<types>
    <name>FlexiPage</name>
    <members>AppDeveloperName_UtilityBar</members>
</types>

Pro Tip: In Salesforce Utility Bar does not get retrieve with apps. 

Connected Apps

Package.xml
<types>
    <name>ConnectedApp</name>
    <members>ConnectedAppApiName</members>
</types>

Approval Processes

Package.xml
<types>
    <name>ApprovalProcess</name>
    <members>Account.Approve_30_Discount</members>
</types>
Pro Tip: Fetch All Approval Processes
<types>
    <name>ApprovalProcess</name>
    <members>*</members>
</types>
Package.xml

Validation Rules

<types>
    <name>ValidationRule</name>
    <members>Objectname.Validation_Rule_Name</members>
</types>

Workflow Rules

Package.xml
<types>
    <name>WorkflowRule</name>
    <members>Object.Workflow_2</members>
    <members>Object.Workflow_2</members>
</types>

Workflow Field Update

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

Process Builders

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

Note: As we know Process Builders are deprecated by Salesforce, So metadata type is Flow for Process Builder.

Email Templates

Package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
      <types>
        <name>EmailTemplate</name>
        <members>New_Folder/New_Templete</members>
        <members>FolderDeveloperName/Template_UniqueName</members>
    </types>
    <version>62.0</version>
</Package>
FYI: How to Find Folder Name?
SELECT Id, Name, DeveloperName FROM Folder

Leave a Reply