Resources /
Blog

How to Deploy Custom Metadata in Salesforce, Plus Settings and Buttons

Submit your details to get a book

7
Min Read
Resources /
Blog

How to Deploy Custom Metadata in Salesforce, Plus Settings and Buttons

Download

Submit your details to get a book

7
Min Read
Glowing bar chart with a rising arrow on a stacked platform, linked to sync, database, list, document and check tiles
Glowing bar chart with a rising arrow on a stacked platform, linked to sync, database, list, document and check tiles

How to deploy custom metadata in Salesforce comes down to one rule: ship the custom metadata type and its records together, because both are deployable Metadata API components. Custom settings work another way, since Salesforce packages their definitions and leaves their data out.

Buttons, links and quick actions are metadata too, yet users only see them where a page layout or list view places them. Below, each one gets its own steps, then the order that keeps a release from breaking.

What's the difference between custom metadata, custom settings, actions and buttons?

Custom metadata and custom settings look alike in Setup, and so do actions and buttons, but each moves in its own way. The table below shows the metadata type behind each and what travels with a deployment.

FeatureMetadata typeWhat a deployment moves
Custom metadata typeCustomObject with an __mdt suffixThe type and its fields
Custom metadata recordCustomMetadata, in the customMetadata folderEach record, as a .md file
Custom settingCustomObject with customSettingsTypeThe definition only, since its records stay out of packages
Quick actionQuickActionThe action, which a page layout adds separately
Button or linkWebLinkThe button, which a layout references by name

What are the steps for a custom metadata type and its records?

A custom metadata type is defined as a custom object with an __mdt suffix, its custom fields end in __c, and its records are CustomMetadata components. The Metadata API Developer Guide prefixes each record name with its type, minus __mdt, so the guide's Planets record in the Reusable Picklist type is ReusablePicklist.Planets.

Name the type, its fields and its records in one package.xml, as in this example built on the guide's samples:

XML: package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>ReusablePicklist__mdt</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>ReusablePicklist__mdt.AlphaSort__c</members>
        <name>CustomField</name>
    </types>
    <types>
        <members>ReusablePicklist.Hotels</members>
        <members>ReusablePicklist.Planets</members>
        <name>CustomMetadata</name>
    </types>
    <version>68.0</version>
</Package>

Then work in this order:

Custom metadata records can also move through code: per the Apex Developer Guide, you deploy custom metadata with the Metadata.Operations.enqueueDeployment() method. The metadata reference notes that Apex code can create, read and update records and deploy them, but not through DML.

How do you deploy custom settings records?

A custom setting is a CustomObject with a customSettingsType of List or Hierarchy, per Salesforce's reference. That definition behaves like any other metadata, so it can go in the same package as the rest of your changes.

The records are another matter, whether you use list custom settings or hierarchy ones. According to the Apex Developer Guide, their data is included in sandbox copies but treated as data for Apex test isolation, so tests need SeeAllData=true to see it.

Plan the records as a separate data step after the definition lands. The Salesforce CLI's data export tree and data import tree commands select records and their relationships with SOQL, write them to JSON files and import them into another org.

Load them before any formula fields, validation rules, flows or Apex that read the setting run in the target. For a hierarchy setting, profile values override organization values and user values override both in Salesforce's hierarchy logic, so confirm each level.

Store nothing sensitive in them: the same guide warns that those outside a managed package are treated as public and readable for all profiles, including the guest user. It points secrets to named credentials or encrypted fields.

How do you deploy custom buttons, links and actions?

A Salesforce custom button or link is a WebLink that can open a URL, and its displayType marks it as a link, a button or a related list button. Quick actions are QuickAction components that work on objects such as Account, Case and custom objects.

Shipping the component alone isn't enough, because users only see what a page layout or the list view's buttons show. Here's where each one is placed, according to Salesforce's reference.

What you shipWhere it's placedDeploy it with
Detail page buttonThe layout's customButtons fieldThe WebLink, its object and the page layout
List view buttonThe object's listViewButtons fieldThe WebLink and its object's search layouts
Related list buttonThe related list's customButtons fieldThe WebLink and the parent's page layout
Quick actionThe layout's quickActionList and, for mobile, platformActionListThe QuickAction, its object and the page layout

Access still matters after the layout lands, so grant it with permission sets. Profile deploys overlay the existing settings, so a missing permission doesn't revoke anything, as our guide to Salesforce profile deployment explains.

If the action lives on a Lightning page rather than a classic layout, include the page assignment as well. Our post on Lightning record page assignments walks through that.

Removing a button or a custom metadata record

Removing metadata is its own step. Per Salesforce's guide, you list the components to delete in a destructiveChanges.xml manifest, which uses the package.xml format without wildcards.

Deletions run before additions by default, and from API version 33.0 you can delete before or after the other components. In Flosum, pre and post destructive changes sit on the branch and run automatically when you validate or deploy.

What order should a mixed release follow?

When a release mixes all of these, order matters. The infographic shows the sequence that keeps references intact.

Infographic of one Salesforce release in seven steps: custom metadata type, its records, the custom setting definition, buttons and actions with their layouts, validate then deploy, load custom setting records, and check as a user

Change sets must be built by hand, the Metadata API guide says, while Metadata API calls can be automated through Salesforce CLI. Our Salesforce DX guide covers that CLI route, and either way, test the whole bundle in a sandbox that mirrors production's layouts first.

Afterward, check the result as a user would. In the target, confirm that:

Keep the package.xml in version control so your teams start the next release from the same custom metadata manifest. Our Salesforce audit trail guide covers tracking setup changes once the release is live.

Deploy with Flosum

Flosum's PreDeploy Fix checks a branch for missing components, broken references and unmet dependencies beforehand, and can retrieve missing metadata. Its Validate step then checks the branch against the target org without deploying and runs Apex tests if needed.

To move records with a release, a pipeline that moves changes between environments can include the Migrate Data operation. It runs a Data Migrator migration as a pipeline step, and Flosum's docs suggest it to seed a target organization with configuration or reference data after a deployment.

If something breaks, Rollback uses the backup snapshot the Deploy job stored, and you pick the components to revert. The DevOps platform also keeps a dependency graph of your org, so "missing references and downstream impacts surface before deployment, never in production."

Our post on Salesforce overwrite protection shows how Flosum's Impact Analysis compares a deployment with the target org first. Flosum DevOps runs in Flosum's cloud or in your own cloud.

FAQs

Can custom metadata records be deployed in Salesforce?

Yes. Each record is a CustomMetadata component in the Metadata API, so list it in package.xml next to its custom metadata type and the fields its values use.

Can you deploy custom settings records with change sets or the Metadata API?

The definition deploys as metadata, but Salesforce packages only the definition, not the data. Move the records in a separate step, for example with the CLI's data import tree command.

Which metadata type is used for Salesforce buttons and links?

Buttons and links use WebLink, with a displayType of link, button or massActionButton. Quick actions use the separate QuickAction type.

Why doesn't my deployed button show up?

A deployed WebLink only appears where a layout or list view references it. Deploy the page layout's customButtons list or the object's listViewButtons with it.

Book a demo to see how Flosum handles custom metadata, custom settings and buttons in one release.

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