Cheatography
https://cheatography.com
Cheat sheet containing common commands for the salesforce CLI
This is a draft cheat sheet. It is a work in progress and is not finished yet.
NOTES
All commands are in the force namespace so must be prefixed with sfdx force:
.
Setup
Create Project |
|
Create scratch org |
org:create -f config_file
|
Generate Password |
user:password:generate -u user
|
Migrating Code/Config
Push to scratch org |
|
Pull from scratch org |
|
Deploy metadata |
mdapi:deploy -u user -d dir
|
Retrieve metadata |
mdapi:retrieve -u user -r dir
|
Cancel metadata deployment |
mdapi:deploy:cancel -u user -i job_id
|
Packaging
Create package |
package:create -n name - t type -r dir
|
Create package version |
package:version:create -p id|alias -d dir -k password
|
Install package |
package:install -p id|alias -k password
|
|
|
NOTES
Most commands require a username or alias to indicate the org to operate on, specified via the -u switch.
Authentication
Login to an org |
auth:web:login {-a alias} {-d}
|
Set default dev hub |
config:set defaultdevhubusername=user
|
Set default scratch org |
config:set defaultusername=user
|
List valid authenticated orgs |
|
List authenticated orgs |
|
Open an org |
|
Logout of an org |
|
DATA
Create a record |
data:record -s sobject -v fields
|
Retrieve a record |
data:record:get -s sobject -i id
|
Update a record |
data:record:update -s sobject -i id -v fields
|
Query one or more records with SOQL |
data:soql:query -q query
|
Delete a record |
data:record:delete -s sobject -i id
|
Bulk upsert |
data:bulk:upsert -s sobject -i ext_id -f file
|
|
|
CONVERT
To source format |
mdapi:convert -r mdpai_dir -d source_dir |
From source format |
source:convert -r source_dir -d mdapi_dir |
TESTING
Run single test |
apex:test:run -t class.test
|
Run all tests in class |
|
Run tests in org namespace |
apex:test:run -l RunLocalTests
|
Run all tests in org |
apex:test:run -l RunAllTestsInOrg
|
Extract code coverage |
apex:test:run -c -r human
|
Run tests when deploying |
mdapi:deploy -u user -r dir -l RunLocalTests
|
OTHER
Display limits |
|
Assign permission set |
user:permset:assign -n psetname -u user -o users |
Execute apex |
apex:execute {-f apex_file}
|
List debug logs |
|
Retrieve debug log |
apex:log:get -i log_id -n lines
|
Tail debug logs |
apex:log:tail -d debuglevel --loglevel level
|
|