Salesforce DX – SFDX – Guide

Hi Devs,

Today I would like to introduce Salesforce DX Guide.

“Salesforce Developer Experience (DX) is a new way to manage and develop apps on the Lightning Platform across their entire life cycle. It brings together the best of the Lightning Platform to enable source-driven development, team collaboration with governance, and new levels of agility for custom app development on Salesforce.” ~ Salesforce

Let’s begin!

Salesforce DX Installation

To install SFDX-CLI we will use npm

Open your command line and check if you have Node.js installed already.
If not, use the following link to download it: https://nodejs.org/en/download/

node --version

In our next step, we need to install SFDX globally.

npm install sfdx-cli --global

More information about SFDX installation for a specific platform you can find here.

How to use Salesforce DX?

Create a Salesforce DX Project

sfdx force:project:create -n MyProjectName --manifest

Replace MyProjectName with your own name.
Congratulation! You created SFDX project with manifest (package.xml) file!

Created project

The project is not connected with salesforce org.

Authorization

Our project is created, no we can connect it with salesforce org.
Replace my-Org-Alias with your own name.

sfdx force:auth:web:login --setalias my-Org-Alias

To specify a login URL other than the default, such as https://test.salesforce.com

sfdx force:auth:web:login --setalias my-Org-Alias --instanceurl https://test.salesforce.com

Salesforce login page should be open. Log in to destination org.

Login Page

Now you can check if everything works as expected by

sfdx force:org:list
Org-list

Retrieve

To retrieve all metadata components listed in a manifest:

sfdx force:source:retrieve -u my-Org-Alias -x manifest/package.xml

More about retrieve options here

Validation

Add -c flag. It’s means check only.

sfdx force:source:deploy -u my-Org-Alias -c -x manifest/package.xml

Deployment

To deploy your code to org use

sfdx force:source:deploy -u my-Org-Alias -x manifest/package.xml

If you want to run Apex Specific Tests. You can use:

sfdx force:source:deploy -u my-Org-Alias -x manifest/package.xml -l RunSpecifiedTests -r TestClass1,TestClass2,TestClass3

More about deploy option you can find here.

If you need some specific cases, more details about SFDX, please add a comment below. I will update following post with additional cases.

Was it helpful? Check out our other great posts here.

Resources

5 4 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Close Menu
0
Would love your thoughts, please comment.x
()
x