How to create Scratch Orgs : Salesforce DX

Now, we will create Scratch orgs in Salesforce using SFDX. Please go through Salesforce DX : An Overview to know basics of SFDX  and Scratch Orgs.

To create scratch orgs we need to firstly enable Dev Hub in your developer org or Production. Follow below steps for that:
1. Log in your Org for which you want to create Scratch org.
2. Click on Setup and search for Dev Hub in Quick find box.
3. Click on Dev hub and then click on Enable Dev Hub.

After Enabling Dev Hub you need to install VS Code and SFDX CLI.
VScode download Link - https://code.visualstudio.com/download
SFDX ClI Download Link - https://developer.salesforce.com/tools/sfdxcli

After downloading and installing these packages open VS Code and press Ctrl+Shift+P it will open the command palette in VS Code. Now, write SFDX in command palette to ensure SFDX cli is installed properly on your system.

Follow below steps and commands to create Scratch Orgs:
1. Open Terminal in VS code.
2. Give this Command - sfdx force:auth:web:login -d -a DevHub 
    For Sandbox use this commandsfdx force:auth:web:login -r https://test.salesforce.com -a FullSandbox
3. It will open you the login page for salesforce. Use your username and password to login and then click on Allow Access. You will see below message in terminal.
4. Now again use Ctrl+Shift+P to open command palette and write SFDX: Create project and press enter and choose Standard and enter name of the project. Please see below the project in VS code-
5. Now run the following Command - sfdx force:org:create -s -f config/project-scratch-def.json -a RTS_ScratchOrg


You will see above message once your scratch org is created.We can also open the Org using the following command -  sfdx force:org:open -u RTS_ScratchOrg

Please provide your feedback and issues in comments.

Comments