Salesforce DX Benefits – Salesforce Developer Experience (DX) is a brand new way to develop and manage apps on the Lightning Platform across the entire life cycle. It combines the best of the Lightning Platform to enable source-driven development, team collaboration with governance, and new levels of agility for custom app development on Salesforce. It facilitates automated testing, continuous integration and improves agility and efficiency of the release cycle. Salesforce DX benefits are much more than just a new set of tools. They serve as an alternative to change set development and shifts the source of truth from Org to Version Control System (VCS). It shifts our development focus from org development to package development and more.
Take a sneak peek into this comprehensive blog encapsulating the Salesforce DX benefits and its significant aspects including the Developer Hub, Salesforce CLI, Scratch Orgs, Metadata Format among many others.
Salesforce DX Benefits – Developer Hub (Dev Hub) orgs
Developer Hub (Dev Hub) is the key Salesforce org that you and your team can use to create and manage scratch orgs.
Here’s how to Enable Dev Hub in your Org.
Alternatively, you can even Get your own 30-day Dev Hub Trial Org here
The Salesforce CLI
One of the key Salesforce DX benefits is the Salesforce CLI, which is used to control the full application lifecycle of the Salesforce apps. With Salesforce CLI, you can slickly create environments for development and testing, synchronize source code between your orgs and VCS, and execute tests. Here’s how to install the Salesforce CLI
- Enable Dev Hub in Your Org. Here’s a quick guide to enabling Dev Hub in your Org. Alternatively, you can Get your own 30-day Dev Hub Trial Org here
- Add Salesforce DX Users
- Install Salesforce CLI. Ensure that you have the latest version of the Salesforce CLI installed and the system meets the necessary requirements. Get the latest version of Salesforce CLI here
Verify Salesforce CLI Installation
- Run the command below to verify the Salesforce CLI version
sfdx-cli/6.0.10-3713d7b alpha (darwin-x64) node-v8.6.0
- Run the command below to verify the Salesforce CLI plug-in version
sfdx plugins –core
salesforcedx 41.2.0 (core)
To learn more about Salesforce CLI installation, see the Salesforce DX Setup Guide.
Salesforce DX Benefits – Scratch Orgs
Scratch org is a fully dedicated, configurable, and short-term Salesforce environment. Scratch orgs enable developer productivity and collaboration during the development process and facilitate automated testing and continuous integration. You can spin up a new scratch org when you want to start a new project or a new feature branch, test a new feature, start automated testing or directly perform development tasks in an org.
Though scratch orgs are meant to be disposable, the scratch org configuration files contain the real brawn. Through the configuration file, you can configure the scratch org with different Salesforce editions and with just the features and settings you want. And you can share the scratch org configuration file with other team members. That way, you will all have the same basic org in which you can develop.
- Scratch orgs are not replace Sandboxes
- Scratch orgs aren’t meant to be replications of sandboxes or production orgs
- A Dev Hub provides us the ability to create and manage scratch orgs.
- Scratch orgs are temporary Salesforce environments where we can do the bulk of development work in this new source-driven development paradigm.
- We can use the CLI or Salesforce Extensions for VS Code to open our scratch org in a browser without logging in
A new Metadata Format
In Ant and the Force.com migration tool, the APIs used by Salesforce DX are the same whereas, in Force.com, migration tool will know that the structure of metadata returned by those APIs isn’t ideal for working from version control system. In general custom objects and profiles can cause these issues –
- Make working with large XML files difficult
- Multiple users making changes to the same files could create conflicts and failing to resolve these effectively can yield corrupt XML
- These items contain a variety of changes pertaining to different features in active development in a specific org – this means when pushing changes, developers need to edit these XML files manually to incorporate only the specific changes they want to push in deployment or commit.
To overcome this, Salesforce DX uses a slightly modified folder structure that breaks up some of the larger, more complex metadata into subcomponents, providing a good workaround to these problems. It’s worth noting, however, that because it uses the same underlying APIs there are still problems this mechanism doesn’t address. It also comes with the added benefit of loosening some of the restrictions on folder structure, allowing you to introduce subfolders to organize your Apex classes.
Visual Studio Code Plugins
Visual Studio Code is a powerful editor. It is highly customizable and is cross-platform. Salesforce extensions provide unique features such as code completion, syntax highlighting, Apex live debugging, and more for the Lightning Platform.
Salesforce has already mentioned that the Salesforce Extensions for VS Code are the future of Salesforce development. They have dedicated their resources to make this the best and most enjoyable desktop editor for Salesforce developers. With this focus on Visual Studio Code, Salesforce is moving away from our support of Eclipse. While the Force.com IDE will be supported and will receive some updates in the near future, the updates will focus mainly on compatibility (and of course, security if needed). Salesforce will not be adding any new major features to the Force.com IDE and we will eventually deprecate it entirely.
How to Install Visual Studio Code?
- Download and install the Latest version of Visual Studio Code. (Skip, if already installed.)
- Install it
How to Install Salesforce Extension Package?
With Salesforce Extensions for Visual Studio (VS) Code, we get a powerful integrated development environment that’s created particularly for custom development on the Lightning Platform. Here’s how to install the Salesforce Extension package
- Launch Visual Studio Code
- On the left toolbar, click the Extensions icon (the last icon down).
- Search for “Salesforce Extension Pack”.
- Install the extension pack
- Click the “Reload” button to re-launch VS Code
Salesforce DX Benefits – Second Generation Packaging (2GP)
Second-generation packaging (2GP) allows customers and system integrators to create packages in a source-driven development environment. You can create and deploy packages in your own Salesforce org or develop and distribute packages to your customers. You can use packaging to take advantage of these unique features.
- The Salesforce CLI provides commands for the entire application lifecycle so you can work efficiently with your packages, scratch orgs, and development processes
- Options for enterprise customers to organize and deploy metadata to production orgs
- Multiple packages per namespace, so you can better organize your source and easily share Apex code. You can use public Apex classes across packages rather than global Apex classes
- Feature branch development and testing
- Completely API-driven functionality
- Packages that are built directly from the source
- Ease of development and distribution of dependent packages
- Unable to Specify a Patch Version
Description: The four-part package edition number includes a patch segment, known as major.minor.patch.build. However, you cannot create a patch for a second-generation package. Package creation fails if you set a patch number in the package descriptor. Stay tuned for patch versions in an upcoming release.
Workaround: Always set the patch segment of the version number, to 0. For example, 184.108.40.206 is valid but 220.127.116.11 is not.
- Protected Custom Metadata and Custom Settings are Visible to Developers in a Scratch Org If Installed Packages Share a Namespace
Description: Use caution when you store secrets in your second-generation packages using protected custom metadata or protected custom settings. You can create multiple second-generation packages with the same namespace. However, when you install these packages in a scratch org, these secrets are visible to any of your developers that are working in a scratch org with a shared namespace. In the future, we might add a “package-protected” keyword to prevent access to package secrets in these situations.
Salesforce DC provides the flexible and powerful Salesforce Command Line Interface (CLI) where we can use CLI to manage package development process from the command line.
The CLI combines capabilities from across several Salesforce APIs, such as Metadata API, Tooling API, and Data (SOAP) API. It also supports the functionality of Ant Migration Tool that allows for scripting of metadata tasks. With the new and improved CLI, all our development tasks from all the important APIs are available in one place. We can script everything from the creation of orgs to the import and export of data–everything required to manage the complete development lifecycle.
To learn more about leveraging the power of Salesforce DX benefits in your organization, Talk to our team!