Sunday, May 3, 2020

SFDX Setup – Dev Hub | Scratch Org | VS Code IDE


Salesforce DX will provide you a series of new tools and features that will change the way developer build Salesforce application.
Salesforce DX introduce a new type of environment which is called as ‘Scratch Org’. To create this scratch org, you need to enable the org as Dev Hub. The scratch will be the copy of Dev Hub though you can configure which parts of your org copy over and it can be disposable over a specified period of time.

Here I will setup SFDX in my Org and will create a Scratch org to implement a lightning component using VS Code IDE and push the component from VS Code IDE to Target org.

Step 1:

Enable Deb Hub in your Salesforce Org. Go to Setup à Development à Dev Hub and click Enable. Once you enable Deb Hub, you cannot disable it again.













Step 2:

Download and Install VS Code IDE.
Download and Install Command Line Interface (CLI). Make sure you have checked the checkbox to set the Salesforce CLI bin path in PATH environment variable while installing CLI.
Open command prompt and run sfdx to check whether CLI installed properly or not

Step 3:

Open Visual Studio Code IDE and Install Salesforce Extension Pack extension.


Step 4:

To create a project in VS Studio Code IDE-
Press CTRL+SHIFT+P
Use SFDX:Create Project, System will ask for SFDX Project Name and then choose the directory where you want to save the project and clicks on ‘Create Project’



Step 5:
Now we are going to integrate the VS Code project to Dev Hub.
Press CTRL+SHIFT+P à SFDX:Authorize a Dev Hub
VS Studio Code IDE will redirect to login Dev Hub and after successfully login, you will get success message in VS Studio for Authorizing a Dev Hub


Step 6:
Now you need to create a Scratch Org by using –
CRTL+SHIFT+P à SFDX:Create a default Scratch Org..


Choose default scratch Org definition JSON


Put a scratch Org Alias name-


Enter the no of day you want to work in the scratch Org. You can choose between 1-30 days. After that no. of days the scratch org will be expired.


Step 7:
Once you get Salesforce CLI message that scratch org has been created, you need to run the below command to open the scratch org-
sfdx force:org:open


So as of now we have created a scratch org from a Dev Hub. Now we are going to create a lightning component in VS Code IDE and move the component to scratch org.

Step 8:
To create a lightning component, CTRL+SHIFT+P à SFDX:Create Lightning Component and give a name to lightning component.



Step 9:
Now we will push the lightning component from VS Code IDE to scratch Org.
Press CTRL+SHIFT+P à SFDX:Push Source to Default Scratch Org
You can see the push request status in Output window. Once push request is successful the same component will be available in the scratch Org to use.





No comments:

Post a Comment