top of page
Writer's pictureAdam Walker

Get to know Salesforce DX

Salesforce DX has been around for a few years now but what’s it all about and why do Salesforce implementations need it?


Let’s take a look at the basics


Source Format


Salesforce DX introduces a brand new format and structure to represent code, configurations and objects. Before we had “Metadata” now we have “Source”.


Metadata has had its limitations particularly in how it structures Salesforce objects which get represented as a single file with all the fields, layouts, list views, validation rules and settings inside. For large Enterprises that may have multiple implementations on a Salesforce instance, this can be problematic due to the size of the file.


Some of my Customers have maintained object files that are several hundreds of thousands of lines long. This makes it difficult for developers to make changes safely and it causes unnecessary complications when merging files in a GIT version control system.


The new Source format addresses these issues by chopping that object file up into separate folders and files that contain the fields, list views, layouts etc. If the developer is simply creating a new field, they will now simply commit a brand new file to version control and have the comfort that they haven’t messed up an existing configuration whilst trying to amend a single huge object file!


Scratch Orgs


Salesforce DX introduces a new type of environment, the Scratch Org. It’s similar to a developer org in the sense that it’s an empty shell. It doesn’t resemble your Production instance like a Sandbox and the idea is for the developer to manage the environment by moving “Source” into the environment as required.


The great thing about Scratch Orgs is how Source is “tracked”, similar to how files in GIT are tracked for changes. If you create a field on Account in a scratch org, you will simple be able perform a Source “Pull” and Salesforce will automatically detect your change and extract that file to your machine.


A Scratch Org is created using a file called the “Scratch Org Definition”. It’s a JSON structure detailing what the initial shape of the empty org might look like. You can define some settings that you might typically find in the Setup menu by setting the “Configuration values” in the JSON Structure.

{
  "orgName": "Hyrule Castle",
  "edition": "Developer",
  "features": ["ForceComPlatform", "MultiCurrency"],
  "settings": {
    "lightningExperienceSettings": {
        "enableS1DesktopEnabled": true
    }
  }
}


SFDX Command Line Interface


The Salesforce CLI is a new suite of tools and utilities a developer might typically use but instead of logging into a nice UI and clicking around – you’ll instead open your terminal/command prompt and type a command to do the exact same thing. This is good for two reasons:

  1. Muscle Memory: You are going to start remembering these commands and supercharge your tasks by writing a command.

  2. Automation: You can write scripted programs and pipelines to perform these commands instead of you typing them.

It takes just a few minutes to install the SFDX CLI on your machine. Once installed, open up a terminal (OSX) or Command Line (Win) and check out all the commands you can use by typing the following:

sfdx commands

Your console will fill up with lots of different commands you can use from Data loading, Scratch Org Creation, Creating Users, Pushing & Pulling Source and much more.

There’s no way you are going to remember all the commands along with all of the options that go with them at the beginning. So to get started, you just need to remember to add –help to any command to get the instructions

sfdx force:org:open --help
open an org in your browser

USAGE
  $ sfdx force:org:open [-p <string>] [-r] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

OPTIONS
  -p, --path=path                                                                   navigation URL path
  -r, --urlonly                                                                     display navigation URL, but don’t launch browser
  -u, --targetusername=targetusername                                               username or alias for the target org; overrides default target org
  --apiversion=apiversion                                                           override the api version used for api requests made by this command
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for this command invocation

DESCRIPTION
  Opens your default scratch org, or another org that you specify.

  To open a specific page, specify the portion of the URL after "yourInstance.salesforce.com/" as --path. 
  For example, specify "--path lightning" to open Lightning Experience, or specify "--path /apex/YourPage" to open a Visualforce page.

  To generate a URL but not launch your browser, specify --urlonly.

  Examples:
     $ sfdx force:org:open
     $ sfdx force:org:open -u me@my.org
     $ sfdx force:org:open -u MyTestOrg1
     $ sfdx force:org:open -r -p lightning
17 views0 comments

Recent Posts

See All

Comments


Commenting has been turned off.
bottom of page