Salesforce DX Absolute Beginner ( Part 3 Of 7 )

In this third part of the salesforce DX series, I am going to show how to set up salesforce dx project from the beginning. I am assuming that you are implementing the new application or project from the beginning. So there is no salesforce metadata is configured. Follow this basic workflow when you are starting the application from the beginning

1. Login into Dev Hub from CLI 

First, you need to login to the Dev Hub from the CLI to start the new project.
 Run the force:auth:web:login CLI command. If you are authorizing a Dev Hub org, use the —setdefaultdevhubusername parameter if you want the Dev Hub org to be the default for commands that accept the —targetdevhubusername parameter.
sfdx force:auth:web:login --setdefaultdevhubusername --setalias my-sfdc-hub-org

After Successful login into the Dev Hub, you can see the success message into the CLI as shown below.

 2. Create an SFDX Project

A Salesforce DX project has a specific structure and a configuration file that identifies the directory as a Salesforce DX project.Use the force:project:create command to create a skeleton project structure for your Salesforce DX project. The force:project:create command generates these samples configuration files to get you started.

sfdx force:project:create --projectname DXLearning

 The force:project:create command generates these samples as shown below.
 3. Create a Scratch Org for Development

You can create scratch orgs for different functions, such as for feature development, for development of packages that contain a namespace, or for user acceptance testing and much other use cases. Use force:org: create to create a scratch orgs .

sfdx force:org:create -f config/project-scratch-def.json --setdefaultusername --setalias my-sfdc-scratch-org

4.Open scratch Org
 You can open scratch org by running force:org:open command from the CLI. After login into the scratch org, you can make any configuration changes. Later you can pull them into local folders.
sfdx force:org:open


sfdx force:org:open -u <username/alias>

5. Push and Pull the code

Go and create some couple of objects in the salesforce scratch org after that we will pull into the local salesforce dx by using the pull commands. You can pull configuration and code from scratch org by using force:source:pull command.
sfdx force:source:pull

Create an Apex Class from the CLI with below command
sfdx force:apex:class:create  --classname CustomerApexController --template DefaultApexClass --outputdir force-app/main/default/classes/

Make some changes to the code as shown below.
Now push the changes to Scratch org from the local development with force:source:push command
sfdx force:source:push
After successfully push, you can able to see the changes in the scratch org
Here are the overall highlights of this post before starting part 4.
  •  Login to the Dev Hub
  • Create a Scratch Org
  • Create Salesforce DX Project
  • Pull changes into Salesforce DX project from the scratch org
  • Make changes locally and push into scratch org.

Salesforce DX Absolute Beginner ( Part 2 Of 7 )

This is the second part of the salesforce DX introduction series. In this second part of series, I am going show the complete set of the salesforce dx installation and the tool that need to required for development. I am going to use Visual Studio for the development.The Salesforce extensions for Visual Studio Code are a set of enhancements for custom development on the Salesforce Platform. If you want to try out Salesforce DX first, you can sign up for a trial org that has Dev Hub enabled.

Salesforce CLI Installation

The Salesforce CLI is a powerful command-line interface that simplifies development and builds automation when working with your Salesforce Org. You install the Salesforce CLI on Windows with a .exe file. You can Download and run the Windows installer from this link.

Visual Studio Code Installation

We are using the visual studio code.Go and download the  Visual Studio code installation from this link.

Salesforce Extensions for VS Code

This extensions bundle includes tools for developing on the Salesforce platform using the Salesforce DX development flow in the lightweight, extensible VS Code editor. These tools provide features for working with scratch orgs, Apex, Lightning components, and Visualforce.

To use Salesforce Extensions for VS Code, install all the extensions in this extension pack.


This extension interacts with the Salesforce CLI to provide basic Salesforce DX functionality. After you install the visual studio code, launch the visual studio code to install the plugins. This extension enables VS Code to use the Salesforce CLI to interact with your scratch orgs. 

To run a command from Salesforce Extensions for VS Code, press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows or Linux) and type SFDX in the command palette.

Command palette, filtered to show SFDX commands

To see the output of the commands that you run, select View > Output, and then select Salesforce DX CLI from the drop-down menu. Alternatively, click Show in the completion notification.


This extension enables VS Code to use the real-time Apex Debugger with your scratch orgs.This extension enables VS Code to use the real-time Apex Debugger with your scratch orgs.


This extension supports Lightning component bundles. It uses the HTML language server from VS Code.


This extension supports Visualforce pages and components. It uses the Visualforce Language Server and the HTML language server from VS Code.

Quick Recap of part 2 before going to part 3.

  • Install DX
  • Install the visual studio code and salesforce plugins
  • sign up for salesforce dx for development.




Salesforce DX for Absolute Beginners ( Part 1 Of 7 )


This is the first part of the salesforce DX introduction series. Salesforce DX is a combination of the set of tools like  Salesforce DX CLI and IDE’s like IDE 2 or Visual code Studio and set of new features that affect the app development lifecycle.Salesforce Developer Experience (DX) is a new way to manage and develop apps on the Lightning Platform across their entire life cycle. It brings together 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.Below are the few highlights of salesforce DX

  1.  Powerful command-line interface (CLI) to manage development lifecycle
  2. Flexible and configurable scratch org which are easy to create and dispose
  3. You can use any IDE or text editor
  4. The ability to apply best practices to software development.
  5. You can use tools to build Continuous Integration and Continuous Delivery.
  6. You can build and test  the application  independently into small packages
  7. Packaging supports for agile distribution
  8. Enable Second-Generation Packaging (2GP) in your org so you can develop 2GP packages.

The below image shows the life cycle of applications development management with Salesforce DX.

Artifact-Based Development

Salesforce DX aims to remodel your development process by providing the major improvements required to manage a complex org with multiple development teams. To realize these improvements, Salesforce DX shifts the model of development from a monolithic org-based development process to a modular artifact-based development process. An artifact is a group of related code and customizations. An artifact can be tested independently from other components in your Org. An artifact should be able to be released independently as well. The metadata components within an artifact can only live in one artifact at a time. The modular artifact-based development gives you more flexibility in managing your teams and releases. You can assign teams to own a particular artifact. Development teams can develop separately and build toward a release of the artifact, and not a release of updates to the Org. With this agile model, you can have more frequent, independent releases, as you can see in the development, build, and deploy flow.

Dev Hub


                        Dev Hub is the First point to start using salesforce DX. Enable Dev Hub in your org so you can create and manage scratch org from the command line and Lightning Experience.   Dev Hub comprises objects with permissions that allow admins to control the level of access available to a user and an Org. You can enable dev from the salesforce development menu under setup.
Once you enabled you can start using the CLI to login into the Dev Hub
sfdx force:auth:web:login --setdefaultdevhubusername --setalias my-hub-org


Salesforce DX is come up with the powerful CLI to interact with application lifecycle. Use the Salesforce command-line interface (CLI) for most Salesforce DX tasks. These tasks include authorizing a Dev Hub org, creating a scratch org, synchronizing source code between your scratch org and VCS, and running tests and other.

You can use CLI in few of the cases

  • Login to the Dev Hub and Create a Scratch Org.
  • Sync Source from and to the Scratch org and Local code base
  • Import and export data setup
  • Test execution
  • Integrate version control and Continuous Integration and Continuous delivery models.

Scratch Org

                    Scratch org short time development org which can be used to develop or build any application on Salesforce.   The scratch org is a source-driven and disposable deployment of Salesforce code and metadata. A scratch org is fully configurable, allowing developers to emulate different Salesforce editions with different features and preferences. And you can share the scratch org configuration file with other team members, so you all have the same basic org in which to do your development.Scratch org drive developer productivity and collaboration during the development process and facilitate automated testing and continuous integration. You can use the CLI or IDE to open your scratch org in a browser without logging in. You might spin up a new scratch org when you want to:
  • Start a new project.
  • Start a new feature branch.
  • Test a new feature.
  • Start automated testing.
  • Perform development tasks directly in an Org.
  • Start from “scratch” with a fresh new org

You can spin the scratch org from the CLI by using the following command

sfdx force:org:create -f config/project-scratch-def.json --setdefaultusername --setalias my-dx-scratch-org
The scratch org definition file(project-scratch-def.json) is a blueprint for a scratch org. It mimics the shape of an org that you use in the development lifecycle, such as the sandbox, packaging, or production.
  • Edition—The Salesforce edition of the scratch org, such as Developer, Enterprise, Group, or Professional.
  • Add-on features—Functionality that is not included by default in an edition, such as multi-currency.
  • Org preferences—Org and feature settings used to configure Salesforce products, such as Chatter and Communities.
    "orgName": "Demo Company",
    "edition": "Developer",
    "orgPreferences" : {
        "enabled": ["S1DesktopEnabled"]

          Setting up different scratch org definition files allows you to easily create scratch org with different shapes for testing. For example, you can turn Chatter on or off in a scratch org by setting the ChatterEnabled org preference in the definition file. If you want a scratch org with sample data and metadata like you’re used to, we have an option for that: hasSampleData as shown below.

  "orgName": "Acme",
  "country": "US",
  "edition": "Enterprise",
  "description": "Work Item #12345: add picklist to widget",
  "hasSampleData": "true",
  "features": ["MultiCurrency", "AuthorApex"],
  "orgPreferences": {
    "enabled": ["S1DesktopEnabled", "ChatterEnabled"],
    "disabled": ["IsNameSuffixEnabled"]

 Salesforce DX Project Structure 

              A Salesforce DX project has a specific structure and a configuration file that identifies the directory as a Salesforce DX project.Use the force:project:create command to create a skeleton project structure for your Salesforce DX project. If you don’t indicate an output directory, the project directory is created in the current location. You can also specify the default package directory to target when syncing source to and from the scratch org. If you don’t indicate a default package directory, this command creates a default package directory, force-app with the project folder name as DXLearning.
sfdx force:project:create --projectname DXLearning

The force:project: create command generates these samples configuration files to get you started as shown below.

The project configuration file sfdx-project.json indicates that the directory is a Salesforce DX project. The configuration file contains project information and facilitates the authentication of scratch org and the creation of second-generation packages. It also tells Salesforce DX where to put files when syncing between the project and scratch org.
below is the sample sfdx-project.json file 
"packageDirectories" : [ 
    { "path": "force-app", "default": true}, 
    { "path" : "unpackaged" }, 
    { "path" : "utils" } 
"namespace": "", 
"sfdcLoginUrl" : "", 
"sourceApiVersion": "42.0"

Overall here are the highlights about the salesforce dx before going to part 2.

  • Dev Hub allows you to create and manage scratch org from the command line.
  • Scratch Org is a source-driven and disposable deployment of Salesforce code and metadata.
  • CLI to interact with Scratch Org, Dev Hub and application lifecycle.