Package.xml to Retrieve All Metadata from Salesforce Org

by Rijwan Mohmmed
package-xml-to-retrieve-all-metadata-from-salesforce-org-techdicer

Hello friends, today we will discuss Package.xml to Retrieve All Metadata from Salesforce Org. Package.xml is an XML file that defines the components and other metadata that make up a Salesforce package. By including the appropriate metadata in your package.xml file, you can retrieve those components and their associated metadata using the Salesforce Metadata API

One way to retrieve LWC components is by using the package.xml file. The package.xml file is an XML file that defines the components and other metadata that make up a Salesforce package.

Note: Complete Package.xml file

Also, check this: Dynamic variables in SOQL Query Apex

Key Highlights :

  1. Create a new package.xml file in the root of your project.
  2. Define the types of metadata that you want to retrieve/deploy in package.xml.
  3. The <members> element specifies the metadata components that you want to retrieve, and the <name> element specifies the type of metadata.
  4. The * wildcard is used to retrieve all components and all types of metadata.
  5. You can retrieve components from salesforce by Salesforce CLI and workbench.
  6. To retrieve all metadata from a Salesforce org, you will need to include the following elements in your package.xml file
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>*</name>
    </types>
    <version>56.0</version>
</Package>

Code :

# Retrieve Tabs and Quick Actions :

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>SampleTab</members>
        <name>CustomTab</name>
    </types>
    <types>
        <members>ObjectName.SampleQuickAction</members>
        <name>QuickAction</name>
    </types>
    <version>56.0</version>
</Package>

# Retrieve LWC Component :

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

# Retrieve Lightning Aura Component :

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

# Retrieve Apex Class :

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

# Retrieve Apex Trigger :

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

# Retrieve Visualforce Page :

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

# Retrieve Visualforce Component :

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

# Retrieve Custom Label :

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

# Retrieve Custom Metadata :

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>CustomMetadataName.SampleRecord</members>
        <name>CustomMetadata</name>	
    </types>
    <version>57.0</version>
</Package>

# Retrieve Custom Object and fields :

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>SampleCustomObject</members>
        <name>CustomObject</name>	
    </types>
    <types>
        <members>ObjectName.CustomFieldName</members>
        <name>CustomField</name>
    </types>
    <version>57.0</version>
</Package>

# Retrieve Flow and Process Builder Process :

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

# Retrieve Email Template & Workflow :

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>FolderName/SampleEmailTemplateName</members>
        <name>EmailTemplate</name>
    </types>
    <types>
        <members>SampleWorkflow</members>
        <name>Workflow</name>
    </types>
    <version>57.0</version>
</Package>

# Retrieve Profile, Roles, Queues, Groups, Permission Set

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Sample Profile Name</members>
        <name>Profile</name>
    </types>
    <types>
        <members>SampleRoleName</members>
        <name>Role</name>
    </types>
    <types>
        <members>SampleQueueName</members>
        <name>Queue</name>
    </types>
    <types>
        <members>SamplePermissionSet</members>
        <name>PermissionSet</name>
    </types>
    <types>
        <members>SampleGroup</members>
        <name>Group</name>
    </types>
    <version>57.0</version>
</Package>

Output :

Reference :

  1. package.xml Manifest Files
What’s your Reaction?
+1
4
+1
1
+1
0
+1
0
+1
2
+1
2

You may also like

Leave a Comment