Salesforce Developer Experience which is the most Trending Topic in these days.
SFDX is a new tool to manage and develop apps on the force.com platform. It is created for developers to build apps on force.com together in a team.
It makes the developers experience easy so that developers can do coding with less effort in a short period of time and build apps together with version control system.
It also changed the way to deploy the application on force.com platform.
Some Import features of Salesforce DX
- Scratch Org
- Source Sync
- Salesforce Command Line Interface(CLI)
- Test Runner
- Continuous Integration
- Force IDE and Visual Studio with DX Support
Let’s start some work on SFDX tool
Download SFDX CLI and install in your System.
Enable DEV HUB in your org so you can create scratch orgs from CLI and use this tool easily or you can create a 30 days trail org in which DEV HUB is by default activated.
Open your Command window and authorize your org
it will redirect to salesforce login page automatically and then enter your DEV HUB org username and password.
After login you will get something like this.
Check your connected orgs.
I have worked on these three org that’s why it’s showing these three orgs list but you will get only one org DevHub if you are using it first time.
You can check the all available things which you can do using SFDX CLI and commands list with explanation by using below two commands
Sfdx force –help
Let’s create a SFDX Project
sfdx force:project:create -n ProjectName
Your Project contains these files and folders.
sfdx-project.json is the project configuration file contains the sfdx project information and it also tell the sfdx where to put all components when you pull data from scratch org.
project-scratch-def.json is the scratch org definition file indicates which type of scratch org will be created and some basic details for scratch org like orgName or edition of Scratch org.
You can manually edit this file like replace Developer edition to Enterprise if you want to create Enterprise Edition scratch org or any other edition.
Force-app folder contains all components like apex class, custom objects, visualforce pages etc..
Create a Scratch Org
sfdx force:org:create -s -f config/project-scratch-def.json -a AliasName
-s indicates this scratch org would be the default scratch org for this project.
-f indicates the path of scratch org definition file
-a indicates the alias name for this scratch org
Alias Name will be helpful when you have multiple scratch orgs. You just need to put alias name for open scratch org instead of using the username of scratch org.
Open Scratch org
This will open the default scratch org if you have otherwise you can use alias name to open other scratch org.
sfdx force:org:open –u AliasName
Create a Apex class in your project
sfdx force:apex:class:create -n ApexclassName -d force-app/main/default/classes
-n indicates the Apex class Name
-d indicates the Path for Apex class in your project
Open Apex class in your project and do some thing and push all changes to scratch org
Push all changes to Scratch org
Let’s review it in the scratch org
Login in to the scratch org by sfdx force:org:open using SFDX it will automatically open your scratch org or you can get list of orgs to know the details of all connected orgs and scratch orgs.
Let’s do some change in the apex class from Scratch org and pull changes you your project.
This Is the way you can sync all changes with your project to scratch orgs.
You can refer some related blog posts or official site for more details-
Hope you find this helpful, in case of any queries/concerns, please post a reply or drop an email to me at [email protected] .