SFDC Stop - Always the latest about Salesforce

Full Tutorial Series with videos, free apps, live sessions, salesforce consulting and much more.

Telegram logo   Join our Telegram Channel

Monday 25 December 2017

Celebrate DXmas with Salesforce DX

Merry Christmas...!!

In this post I am going to talk about Salesforce DX. So, after the celebration of Christmas, let's celebrate DXmas together by learning what Salesforce DX is and how can we use it to increase our productivity.

Well, the first question that comes in your mind is What is DX in Salesforce ? 
DX stands for Developer Experience. Salesforce focuses on enhancing the developer experience through this new feature. There are some specific terms that you will hear every time you learn about Salesforce DX, whether it's during a live demo session or reading about it in a blog post like mine. Let's learn about those terms first so that we'll be aware of these whenever we'll hear about them in future.

1. Source of Truth

A source of truth is simply a source for accessing and modification of a data element. Till now we have worked on Org Based Development Model in which every data related to a project resides in an Org. So, earlier our development org was our Source of Truth but the concept of Salesforce DX focuses on the point that your VCS (Version Control System) repository in which your code resides is your source of truth. That can be a repository on Github, Bitbucket  or any other VCS that you use to prefer Salesforce supports all VCS. Salesforce DX focuses on Artifact-Based development in which we divide the whole project into different applications/features and then we develop and release each feature individually as a single artifact.

2. Artifact 

An artifact is simply a group of related code and customizations. It can be developed, tested and released independently as well. The point to be noted in that while talking about a salesforce project, the metadata components that reside in one artifact cannot reside in any other artifact at the same time. This means that we have to make relationships between artifacts if other artifact components require metadata from a different artifact. It's similar to as we make a base test class that can be used by other test classes for the creation of data.

3. Scratch Org

You'll hear about scratch org in each and every article related to Salesforce DX and even at every session you attend. So the question here is - What is a Scratch Org ? Scratch Orgs are simply Salesforce Development Environment in which you do the development. As salesforce mainly focuses on artifact based development, so it is preffered to keep all your code and customizations for a particular artifact in a single scratch org. and make regular commits to your repository. The important point to note about a Scratch Org is it's life span is only for 7 days. Salesforce has make such decision because it wants you to store your code and customizations into your VCS instead of org as your VCS Repo is not your Source of  Truth. However, if you have such requirement, like you are working on any big feature, you can extend your scratch org life span to 30 days at max.

4. Developer Hub Org

A developer hub org is the place where you can create and manage your scratch orgs. You can signup for a 30 day trial of your developer hub org here. It is similar to a Salesforce Org but has the capability to create and manage all your scratch orgs. If you have a production org or a business org, you can enable devHub from there just follow these steps:- 
  •  Go to Setup
  • Search for Dev Hub
  • Click Enable
So, in this way you can enable a Dev Hub for your production or business environment. Once you enable the dev hub, you can't disable it. Here is how your DevHub Org looks like:- 

As you can see above, you can easily view and manage all your scratch orgs from here. But we are developer and we love to work on CLI right ? Don't worry, Salesforce has that option for you too.

5. Salesforce CLI

Salesforce CLI is a command line interface using which you can use Salesforce DX and all it's command to interact with your scratch org. You can download it here. and install it on your system.

6. Extensions

Salesforce has provided a number of extensions for various IDE so that they can be DX compatible. What I personally recommend is to use Visual Studio Code for the same. Here you can easily work on your apex code as well as you can use DX commands to push or pull your metadata from your org and your VCS too through general VCS commands. You can download the Visual Studio Code here.
After installing, you can add an extension to your Visual Studio Code from here. This extension will make writing apex code easy and also you can interact with your scratch orgs in a much flexible way.

So, now you are perfectly ready for making a move towards Salesforce DX. So, I recommend you to go through the document in this link:- Hands-on Workshop: Using Salesforce DX for Lightning Development. Its the step by step approach on how you can use Salesforce DX for developement by Shashank Srivatsavaya (Developer Relations Manager/Evangelist, India). After that you can go through some other important links I am mentioning below:- 

  1. App Development with Salesforce DX - Trailhead
  2. Continuous Integration Using Salesforce DX - Trailhead
  3. Salesforce DX Setup Guide - Salesforce Docs
Thanks for reading. You can suggest more topics that you want to learn and I'll try my best to make you understand those in the easiest possible manner. You can reach out to me by messaging here directly or onto my twitter handle @rahulcoder

Have a great Christmas and a Happy New Year 2018


  1. This comment has been removed by a blog administrator.

    1. Hello Miss, please don't post any kind of spam here. This blog is solely for the help of Salesforce Trailblazers and any external link will be considered as spam. I am going to delete it right now.