In Dreamforce Salesforce announce a new development tool SFDX. It’s a new way of development where we create a temporary org for the development; In SFDX we call them Scratch org. The idea is similar with Trailhead org where we create new org for challenge and once completed we can delete them as well. SFDX in Salesforce is game changer as we can use them with any size of teams.

With recent Salesforce releases we are getting updates related to SFDX and as its GA now so I did a quick check to see how it works and how we can best use it. The main part SFDX cover is related to Source control. With SFDX and many VCS (like github) we can easily do version control. SFDX is a command line tool but we can also use Visual studio plug-in to do the development. Today we will cover how we can quickly setup the SFDX up and running.
First you need a Dev Hub org. You can signup for a trial org from here. https://developer.salesforce.com/promotions/orgs/dx-signup
macOS | https://sfdc.co/sfdx_cli_osx |
Windows 32-bit | https://sfdc.co/sfdx_cli_win |
Windows 64-bit | https://sfdc.co/sfdx_cli_win64 |
Debian/Ubuntu 64 | https://sfdc.co/sfdx_cli_linux
Download the archive from one of the URLs in the manifest, extract the archive, then run the ./install script. |
Debian/Ubuntu x86 | https://sfdc.co/sfdx_cli_linux_x86 |
Then we can download CLI from here and we need to make sure we have properly installed it.
Then first we need to do login in our devhub org and authenticate the SFDX to use that.
sfdx force:auth:web:login -d -a DevHub
You can create alias for org so that it is easy to remember and can quickly type them in CLI. We can use sfdx force:org:list to see all active org.
First you need to create a local project where you will store all your metadata.
sfdx force:project:create -n MyOrg

Next we will create a new scratch org where we do all our development.
sfdx force:org:create -s -f config/project-scratch-def.json -a MyScratchOrg

- The -s option indicates that we want this scratch org to be the default org for this project.
- The -f option is the path to the project scratch org configuration file.
We can also export data using SFDX to populate our new org with data.
sfdx force:data:tree:export -q "SELECT Id,Name FROM Account" -d ./data
To Import this data we can use import command.
sfdx force:data:tree:import --sobjecttreefiles data/Account.json
We can also create classes, pages, lightning component using SFDX
sfdx force:apex:class:create -n AccountController -d force-app/main/default/classes
sfdx force:lightning:component:create -n AccountLocator -d force-app/main/default/aura
To Push and Pull data from,to scratch org we use Push and Pull commands.
sfdx force:source:pull
sfdx force:source:push
We can use sfdx force:org:open -u OrgAlias command to open any org in browser
To generate password for any scratch org we use the password generate command.
sfdx force:user:password:generate -u OrgAlias
We can also get list of all org using list command
sfdx force:org:list

To get current org details we can use org:display command.
sfdx force:org:display -u MyScratchOrg (OrgAlias)

So these all are basic steps using which we can easily configure SFDX in no time. In next post we will cover How we can use Git with SFDX and How we can use Visual Studio to develop the SFDX.
We can also use SFDX in Salesforce with non scratch org. You can check that in details here.
Did you like the post or want to add anything. Let me know in comments section. Happy Programming. 🙂
5 thoughts on “SFDX: A New Way of Development”