All Salesforce DX Commands List

Salesforce  provide Command Line Interface to increase productivity with integrated tools. Using this tool(Salesforce DX) you can create SF Org, apex class, lightning component, visualforce page and so on. You have to download and install tool  on you local machine. Please use following table to download Salesforce DX tool. Reference from https://trailhead.salesforce.com

OSDownload URL
Windows 32-bithttps://sfdc.co/sfdx_cli_win
Windows 64-bithttps://sfdc.co/sfdx_cli_win64
macOShttps://sfdc.co/sfdx_cli_osx
Debian/Ubuntu 64https://sfdc.co/sfdx_cli_linux
Debian/Ubuntu x86https://sfdc.co/sfdx_cli_linux_x86

Whenever finish installation open you command window to test sfdx command

Note: All command example from Window OS
C:\Users\ADMIN>sfdx
If Salesforce DX installed on your system above command will produce following output
Salesforce DX
C:\Users\ADMIN>sfdx help force when you run this command this command return all command list that support by Salesforce DX.

All command suffix by sfdx command

Command NameDescriptionExample
force:apexWork with Apex code

Syntax will be like –> sfdx force:apex:class:create n class_name d forceapp/main/default/classes

-n means required component name

-d means required directory path where component created in local machine

force:apex:class:create (create an Apex class)
force:apex:execute (execute anonymous Apex code)
force:apex:log:get (fetch a debug log)
force:apex:log:list (list debug logs)
force:apex:log:tail (start debug logging and display logs)
force:apex:test:report (display test results)
force:apex:test:run (invoke Apex tests)
force:apex:trigger:create (create an Apex trigger)
force:authAuthorize an org for use with the Salesforce CLI force:auth:web:login
force:configConfigure the Salesforce CLI force:config:get (get config var values for given names)
force:config:list (list config vars for the Salesforce CLI)
force:config:set (set config vars for the Salesforce CLI)
force:dataManipulate records in your org
force:docDisplay help for force commands
force:lightningCreate and test Lightning component bundles
force:limitsView your org’s limits
force:mdapiRetrieve and deploy metadata using Metadata API
force:orgManage your Salesforce DX orgs
force:packageInstall and uninstall first- and second-generation packages
force:package1Develop first-generation managed and unmanaged packages
force:package2Develop second-generation packages
force:projectSet up a Salesforce DX project.force:project:create -n your-proect-name
force:schemaView standard and custom objects
force:sourceSync your project with your orgs.

pull only source code into your local machine from your configured ORG which are not sync.

push only unsync source code form local machine to configured ORG

 force:source:pull 

force:source:push

force:userPerform user-related admin tasks force:user:create (create a user for a scratch org)
force:user:display (displays information about a user of a scratch
org)
force:user:list (lists all users of a scratch org)
force:user:password:generate (generate a password for scratch org users)
force:user:permset:assign (assign a permission set to one or more users of
an org)
force:visualforceCreate and edit Visualforce page force:visualforce:component:create (create a Visualforce component)
force:visualforce:page:create (create a Visualforce page)
force:aliasManage username aliases force:alias:list (list username aliases for the Salesforce CLI)
force:alias:set (set username aliases for the Salesforce CLI)

 

Set default dev hub username

Note: Here you can get error if you running above some commands. For Example let’s try to create org from scratch use command: sfdx force:org:create -s -f config/project-scratch-def.json -a your-org-name
ERROR: No defaultdevhubusername org found.

Above error will be fixed by sfdx force:config:set [email protected] –global

After setting default username of your development hub org now you are able to run command to create dev org from scratch. Now you can use a command to open new created org by C:\Users\ADMIN\your-project-dir>sfdx force:org:open (this command return an url to open your created org without login)

Use Salesforce DX command to create Apex Class AND Lighting Component

1. Let’s create lightning Component by CLI using sfdx command
C:\Users\ADMIN\your-project-dir>sfdx force:lightning:component:create -n cmp_name -d force-app/main/default/aura (-n means required component name and -d means required directory path where component created in local machine)

2. Let’s create Apex class by CLI using sfdx command

C:\Users\ADMIN\your-project-dir> sfdx force:apex:class:create n class_name d forceapp/main/default/classes

Comment please if you like this post.

Leave a Reply

Your email address will not be published. Required fields are marked *