Resources /
Blog

Salesforce Metadata Deployment: Methods, Steps and Change Control

Submit your details to get a book

7
Min Read
Resources /
Blog

Salesforce Metadata Deployment: Methods, Steps and Change Control

Download

Submit your details to get a book

7
Min Read
Salesforce metadata deployment: a data mapping panel on a stepped platform, linked to transfer, database, list and document tiles
Salesforce metadata deployment: a data mapping panel on a stepped platform, linked to transfer, database, list and document tiles

Salesforce metadata deployment moves configuration and code, such as objects, fields, flows and Apex classes, from one org to another. The usual route is sandbox to production, using change sets, the CLI, Lifecycle Center (formerly DevOps Center) or a DevOps platform.

Choosing a method is quick, but the change management around it takes more care. Below, the four methods sit side by side, followed by a sandbox to production walkthrough, common errors and the controls auditors check.

What is metadata deployment in Salesforce?

Metadata describes how your org is built, and data is the records inside it. A metadata deployment copies that build, so a new field, layout or setting reaches the target org without touching records.

Salesforce's Metadata API deploys, retrieves and moves these customizations between orgs. Our guide to common Salesforce metadata types covers what they contain, and custom metadata deployment has rules of its own.

A single deploy is capped at 39 MB compressed, and Apex needs tests that pass and cover at least 75% of your Apex code before it can go live. RunLocalTests is the default for production deploys that include Apex, so every test outside managed packages runs unless you set another level.

How do you deploy metadata between Salesforce orgs?

There are four common ways to move metadata between orgs. The table compares how changes travel in each and where each one fits.

MethodHow changes moveVersion historyBest fit
Change setsPicked by hand in Setup and sent over a deployment connectionNoneSmall teams with a few releases a year
Salesforce CLI and Metadata APIFiles retrieved to a local project, then deployed from it or from a manifestYes, once the project is committed to GitDeveloper-led teams comfortable with scripts
Lifecycle CenterWork items promoted through a pipeline of environmentsSource control is the single source of truthTeams that want Salesforce's own pipeline tool
DevOps platform such as FlosumPipelines with approvals, tests, dependency checks and rollbackBuilt inParallel work, many orgs or regulated releases

Change sets need a deployment connection, which only links orgs affiliated with the same production org, and each change set is limited to 10,000 files. Our change set guide walks through building one and the limits teams hit.

The Salesforce CLI pulls metadata with sf project retrieve start and pushes it with sf project deploy start. Because the files sit in a project folder, they can go into version control like any other code.

Lifecycle Center opens from the App Launcher with no package to install, and it uses GitHub or Bitbucket Cloud for source control. Our Lifecycle Center vs change sets comparison covers where it stops short.

Change sets vs automated deployment: which should you use?

Change sets suit a single admin moving a handful of components now and then. Once several people work in parallel, an automated pipeline takes over the steps change sets leave to people.

AreaChange setsAutomated pipeline
Where it runsSetup, between orgs linked to the same production orgCLI, Lifecycle Center or a DevOps platform, across the orgs you connect
Picking componentsBy hand for every change setFrom version control or a package.xml manifest
ValidationValidate in the target org before deployingCheck-only deploy with tests at each promotion
RollbackA completed deployment can't be rolled backRedeploy an earlier commit, or use the platform's rollback
Change historyWhat the target org recordsEvery change committed with its author and reason
Audit evidenceSetup Audit Trail, kept for 180 daysApprovals and test results stored with each release

Salesforce says a completed change set deployment can't be rolled back. Undoing one means rebuilding the old version and redeploying it by hand.

Teams moving off change sets can follow our plan for migrating from change sets. It sets out the steps in order, so releases keep going during the switch.

How do you deploy metadata from sandbox to production?

The steps below follow a CLI or pipeline deployment, and most tools use the same order. Each step catches a different kind of problem before production sees it.

  1. Retrieve the changed components from the Developer sandbox, or list them in a manifest with sf project generate manifest.
  2. Commit the files to version control, so every change has an author and a reason.
  3. Promote through your test environments, where Partial Copy and Full sandboxes hold a sample or a full copy of production data.
  4. Validate against production with sf project deploy validate, which runs Apex tests and returns a job ID without deploying.
  5. Record the approval and the validation's test results before the release window.
  6. Deploy in the agreed window, and hold releases during freezes such as month-end close. A validation from the last 10 days can go out as a quick deploy without rerunning tests.
  7. Check the change in production, then refresh lower sandboxes so they don't drift.

Deletions take a separate route through a destructiveChanges.xml manifest. Metadata API removes every component it lists, so one wrong line takes a component out of the org.

For the release process around these steps, see our Salesforce deployment best practices. It covers planning, sign-offs and post-release checks in more depth.

What causes Salesforce metadata deployments to fail?

These are the failures worth checking for before every release. Each one is cheaper to catch in validation than to fix in production.

Start with missing components. A field may reference a picklist value set that wasn't included, or a flow may call an Apex class that never left the sandbox.

Profiles and permission sets often reference fields and objects that don't exist yet in the target org. Our guide to deploying profile metadata covers shipping them with the components they refer to.

Conflicts appear when two people change the same component in different sandboxes. Without a version check, the later deployment overwrites the earlier one, which is where merge conflict resolution comes in.

Test failures round out the list. Code that passed in a sandbox can fail against production data, or fall short of the 75% coverage rule.

Metadata API quirks

A wildcard in package.xml can't retrieve standard objects or managed package components, so each one has to be named, with the namespace prefix for packaged components. Even a named standard object leaves out standard fields that can't be customized, such as CreatedById.

Some metadata types aren't supported by Metadata API, so changes to them are made by hand in each org. First-generation managed packages deploy on their own, because InstalledPackage must be the only type in its manifest.

How does change management work for metadata deployments?

Change management is the record and the rules around each deployment. It answers what changed, who asked for it, who approved it and what happened in production.

Setup Audit Trail logs setup changes with the date and the person who made them, and deletes those records after 180 days. Event Monitoring adds a log of Metadata API retrieval and deployment requests.

Neither record ties a deployment to the request that approved it. A governed pipeline closes that gap by making approval a step the release can't skip.

The request, approver, components, test results and outcome then sit in one record. Duties stay separate too, since the person who builds a change doesn't approve it and nobody edits production directly.

How Flosum handles Salesforce metadata deployment

Flosum DevOps runs in Flosum's cloud or in your own cloud. Its DevOps Cloud App brings version control, approvals, automated testing and one-click rollback into one platform, as part of a wider Salesforce DevOps process.

Because the org's metadata is committed, the app keeps a dependency graph of it, and PreDeploy Fix flags missing components and unmet dependencies before a change deploys. A failed release can be rolled back from its pre-deployment snapshot, and each release keeps its approvals in the audit trail.

FAQs

What is the difference between metadata and data in Salesforce?

Metadata is the structure and logic of an org, such as objects, fields, layouts, flows and Apex code. Data is the records stored in those objects, so a metadata deployment changes how the org works without moving any customer records.

Can you deploy metadata from production to a sandbox?

Yes, because change sets work between orgs affiliated with the same production org, and the CLI can deploy to any org you authorize. A sandbox refresh is the other route, since it updates the sandbox's metadata from its source org.

What is a package.xml file in Salesforce?

A package.xml file is a manifest that lists the metadata components to retrieve or deploy, by type and name. The Salesforce CLI can generate one from a project or an org.

Do Apex tests run when you deploy to production?

Yes, whenever Apex goes to production, because its tests must pass and cover at least 75% of your Apex code. A validated deployment can then go out through quick deploy within 10 days without a second test run.

Is there an alternative to change sets?

The Salesforce CLI, Lifecycle Center and DevOps platforms such as Flosum all replace change sets. They add version control, repeatable pipelines and, in the case of a platform, approvals and rollback.

Book a demo to see how Flosum validates and deploys Salesforce metadata with a full audit trail.

Table Of Contents
Author
Stay Up-to-Date
Get flosum.com news in your inbox.

Thank you for subscribing

Ship Salesforce changes faster
Teams on Flosum report 40% higher development velocity and 75%
fewer merge conflicts.
Free to start  |  No credit card required