Salesforce DX is the most exciting thing to happen to Salesforce developers since Lightning. It’s a fundamental shift in how developers can deliver apps on the platform. It leverages many of the major improvements that have emerged in software delivery over the past five years. It encourages the use of source control. And it paves the way for continuous integration for Salesforce.
DX is more of a movement than a specific feature or product. It’s a change to the way you develop.
What DX Can Do For You
Salesforce developers are awesome because they are practical. They generally aren’t interested in esoteric solutions. So what specifically can Salesforce DX do for you?
First, Salesforce DX encourages best practices around source control. You should back up your code changes. You should keep a version history. This allows you to rollback to previous states and audit changes over time (ideal for SOX compliance for Salesforce). DX does not provide source control for you but it’s a paradigm shift that encourages its use (we’ll explain later how Blue Canvas can make adopting source control easier for Salesforce developers and admins).
Second, Salesforce DX introduces the concept of scratch orgs. Scratch orgs are simple sandboxes. They can be spun up in a few minutes instead of the typical multi-hour sandbox creation time. You can use these as temporary developer environments where you can make changes. This is nice because it allows you to better compartmentalize work. Instead of having a sandbox with hundreds of different features on it (that you have trouble keeping track of), DX allows you to have different scratch orgs for different units of work. Each scratch org is independent and can be used to do feature work.
Ultimately, DX makes Salesforce development safer and more efficient.
How to Get Started with Salesforce DX
To get started with DX, we recommend the Trailhead Quick Start: Salesforce DX. This gives you a pretty quick overview of how to use it.
To get started, enable DX for your account. If you have a production or business org the Trailhead will show you how to do this. You can also just quickly spin up a Dev Hub for free. The aptly named Dev Hub is a hub from which you can spin up scratch orgs.
Once you have created your Dev Hub, you just need to download the Salesforce DX CLI.
It is available for download for Windows, Mac and Ubuntu here. Type
sfdx into the terminal to confirm that it worked. You should see something like:
Usage: sfdx COMMAND [command-specific-options] Help topics, type "sfdx help TOPIC" for more details: sfdx force # tools for the salesforce developer sfdx plugins # manage plugins sfdx update # update sfdx-cli
Next, authorize the newly installed CLI to connect to your Dev Hub:
sfdx force:auth:web:login -h
This allows you to create scratch orgs from the command line. Your browser should automatically open and prompt you to login to the Dev Hub. Since you can have multiple Dev Hubs you may want to create an alias so you know which hub you are working with:
sfdx force:auth:web:login -d -a MyAlias
You should see something like:
Successfully authorized <your-username> with org id 00A1I000000L9r3HGV You may now close the browser
Now you’ll need a Git repository. Salesforce provides some sample projects on GitHub that you can clone. For example, you can try it out with the DreamHouse app that they show in all their demos here:
git clone https://github.com/forcedotcom/sfdx-dreamhouse
Creating a scratch org is as simple as:
sfdx force:org:create -s -f config/sfdx-project.json
This will leverage the configuration settings that are in the file
sfdx-project.json. You will then want to configure a username so that you’re pushing to the right scratch org:
You can then populate the scratch org with the sample project metadata by simply pushing to the scratch org from the command-line:
If you want to launch the scratch org in the browser simply:
sfdx force:org:open --path one/one.app Waiting to resolve the Lightning Experience-enabled custom domain..........
Blue Canvas Makes Salesforce DX Integration Easier
DX is awesome, but as you can see there are some things you might want to do that require additional work. First, you have to set up your own source control system with something like GitHub or Bitbucket. Blue Canvas is a source control system designed specifically for Salesforce which takes a lot of the manual and expensive steps out of setting up source control. Also, you may notice that DX is a very command-line heavy tool. This may not be ideal for everyone on your team. Right now you must use the command line to spin up scratch orgs.
Let’s say you want to use scratch orgs to test new features out before deploying. You want to grab all the metadata from your sandbox throw it in a scratch org for testing. (Many teams are imagining using scratch orgs in this way to create feature branches.) There is a challenge though: scratch orgs and sandboxes have different directory structures. So porting metadata from a sandbox to a scratch org is not trivial. Though DX is the future, Sandboxes don’t appear to be going anywhere soon and having the ability to connect sandboxes and scratch orgs is important.
The Blue Canvas Salesforce DX integration aims to bring you all the awesomeness of Salesforce DX while making it easier to use than ever. Kind of like GitHub did for Git. Before GitHub, Git was a great tool but felt esoteric. GitHub put a beautiful UI in front of Git and it helped Git become this amazingly popular tool.
With Blue Canvas you can automatically spin up a scratch org with the click of a button. No command-line necessary. We can automatically populate the scratch org with your sandbox metadata so it is ideal for feature branching. We automatically normalize the scratch org and sandbox directory structure for you so you don’t have to do anything.
Source control is built in. When you spin up the scratch org we simultaneously create a feature branch for that scratch org and link it to that scratch org. Any changes that you make on the scratch org are automatically committed to that branch. Doing it this way allows you to keep your work small and modular. No need to keep track of multiple features on one sandbox. You can have multiple features being developed safely simultaneously.
When you want to deploy the feature back into the sandbox or up to UAT or production, you just click a button and we do a Git diff between the target environment and the scratch org. We check for merge conflicts and validate changes. Deploying back into the target environment is simple. Just click a button, select the components to include and click Deploy. We will merge the code back into the mainline branch as we simultaneously deploy to the sandbox. We won’t deploy if we can’t merge and we won’t merge if we can’t deploy. Deployments and source control merges are now handled in a single automated step. No manual processes and no danger of your Git repo saying something different from your org.
How Blue Canvas Can Have You Using Salesforce DX in 5 Minutes
Blue Canvas makes DX accessible to Salesforce developers and admins of all stripes. If you’ve had curiosity about DX but haven’t had time to get started, check out the Blue Canvas integration. To get invited to the beta, email firstname.lastname@example.org.