Salesforce DX is Salesforce's set of tools and practices for source-driven development: the Salesforce CLI, a source format designed for version control, temporary scratch orgs created from a definition file, and second-generation packages. Salesforce DX lets teams treat source code and metadata in a repository as the source of truth, instead of the org itself.
Key Salesforce DX Concepts
- Salesforce CLI runs commands to create orgs, retrieve and deploy source, run tests, and build packages.
- Source format splits metadata into smaller files than the Metadata API format, which suits version control.
- Scratch orgs are short-lived orgs created from a configuration file for development and testing.
- Dev Hub is the org that creates scratch orgs and owns second-generation packages.
- Second-generation packages, unlocked or managed, bundle metadata into versioned units that install into other orgs.
How to Approach Salesforce DX
- Enable a Dev Hub and install the Salesforce CLI.
- Create a project in source format and put the project under version control.
- Develop in scratch orgs, pushing local changes to the scratch org and pulling changes made in the scratch org back to the project.
- Package where it helps. Group related metadata into unlocked or managed packages with versions.
- Install versions into sandboxes and production through a controlled release process.
How Snapshot Helps
- Developer Project: for Salesforce DX projects, Push Pull Source selects a scratch org, Refresh Status List shows local and remote changes, and Source Push and Source Pull sync changes. Take Snapshot makes the project available for reports and deployment. Salesforce DX File Format requires the Salesforce CLI.
- Create Packages: creates second-generation managed or unlocked packages and package versions from Salesforce DX project metadata in a Dev Hub, now or on a schedule. Managed packages require a namespace, and a package needs at least one version before installation elsewhere.
- Install Packages: installs and uninstalls second-generation packages in a destination org, with installation keys, queued in order, now or on a schedule.
Package existence in the Dev Hub does not establish successful installation or correct behavior in a target org.
Metadata Types Involved
-
InstalledPackage: a first-generation managed package to install or uninstall through the Metadata API.
Common Questions
What is a scratch org?
A scratch org is a temporary Salesforce org created from a configuration file for development or testing. Scratch orgs expire after a set number of days.
What is the difference between unlocked and managed packages?
Unlocked packages are mainly for organizing an org's own metadata and allow changes in the installed org. Managed packages require a namespace, protect intellectual property, and are typical for AppExchange distribution.
Can admins use Salesforce DX without writing code?
Yes. Admins can retrieve declarative changes into a DX project and deploy them like code, though the CLI and source control add a learning curve.