What is Salesforce CLI?
Salesforce CLI helps simplify build automation and development within a Salesforce organization. It accumulates various Salesforce APIs. It can run through the terminal and can be easily scripted, facilitating automation in turn. Users can manage tokens and move source data as well as metadata across various environments, with the help of Salesforce CLI.
Watch this Salesforce Tutorial for beginners:
Salesforce CLI is based on an open-source framework used in building a command-line interface in Node.js, called Oclif.
The Salesforce CLI commands help scratch org while also supporting statements for the management and creation of the org. The SFDX platform helps in controlling the process of importing and exporting data. It also helps by supporting the systems of executing of installation and testing of the packages.
The Salesforce CLI is mostly associated with Salesforce Developer Experience or SFDX. Hence, it is often referred to as SFDX CLI. While dealing with SFDX commands, users come across various situations where they need to include references. The reference statements contain the Salesforce parameter information, within the org.
Salesforce CLI is enabled by SDFX, followed by a command which can be found from a list of commands.
SFDX CLI Installation Packages
The Salesforce DX CLI installation packages are mentioned below:
- Alias Namespace
Alias Namespace packages are used to manage username aliases.
- Auth Namespace
Auth Namespace packages are important to authorize the Salesforce org. This facilitates the accommodation and usage of Salesforce CLI.
- Force Namespace
Force Namespace is important for the growth of the field objects and the values on the Salesforce platform.
- Help for Salesforce CLI Commands
These are important as they show users the details that are embedded with the line interface of a topic in Salesforce.
- CLI Deprecation Policy
The CLI Deprecation Policy deprecates CLI commands and parameters.
- Discover Salesforce Plug-ins
These plug-ins help users check out other plug-ins working according to Salesforce features.
Master Salesforce Administration, App Builder, and SFDC! Check out our Salesforce Training Course!
Uses of Salesforce CLI
Some of the main uses of Salesforce CLI are as follows:
- It can gather all the necessary tools required for the development and perform commands against a Salesforce organization.
- It allows you to synchronize sources to and from scratch organizations.
- It can be used to manage and create organizations.
- It can be used to export and import data.
- It allows users to execute as well as create tests.
- It can also be used to install and create packages.
Data Loader in Salesforce
Data Loader is a client application that is used to import and export data in bulk. It can be used to update, import, export, or delete records from Salesforce. While importing data, Data Loader loads, extracts, and reads data from .csv files or a database. While exporting data, Data Loader gives .csv files as output.
You can use Data Loader in two different ways:
- Salesforce Data Loader User Interface – With the User Interface, the work can be done interactively to specify .csv files used for export and import, the field mappings used to map field names, and the parameters for configuration.
- Salesforce Data Loader CLI – With the CLI, the data sources, actions, mappings, and configurations are specified. This helps to set up Data Loader for automated processing.
Data Loader CLI
Data Loader CLI proves useful when a user has to load data repeatedly at a specified time. But, the Data Loader CLI is only available on Windows hosts.
You can follow the steps below to use the Data Loader CLI on a Windows system:
- Generate a key to encrypt your organization’s password
- Encrypt the password of your Salesforce environment using the key
- You also need to create the mapping file and save it as a .sdl file
- Create a process-conf.XML file according to your needs
- Enter the final command and run the process so the data can load
Prepare for Salesforce job interviews with these Salesforce Interview Questions and Answers!
Salesforce CLI Download
The procedure for downloading Salesforce CLI depends on the host system’s operating system.
System Requirements for Salesforce CLI
Before downloading the Salesforce CLI on your system, you should review the following system requirements.
Salesforce CLI supports the following operating systems:
- Windows—Windows 8.1 and Windows Server 2012 (64-bit and 32-bit) or later
- Mac—macOS 10.11 or later (Intel and M1)
- Linux—Ubuntu 14.0.4
Code Editor or IDE
Users can use any code editor, even Salesforce Extensions for VS Code. It is a set of Visual Studio Code extensions designed for developments carried out on the Salesforce platform.
Version Control System
Users can use any Version Control System or VCS. Salesforce recommends GitHub as it contains samples in the Salesforce GitHub repository.
Every Salesforce CLI installer contains Node.js which is updated as new Node.js releases are out.
You can follow the steps below to download and install Salesforce CLI on your system.
Salesforce CLI Installation on macOS
The Salesforce CLI installation on macOS is done using a .pkg file.
- You can download the .pkg file here.
- Run the .pkg file and answer all prompts.
- Once the installation is complete, restart the Terminals or IDEs.
Salesforce CLI Installation on Windows
The Salesforce CLI Installation on Windows is done using a .exe file.
- You can download the .exe file here – x64 or x86.
- Run the .exe file and answer all prompts.
- Once the installation is complete, restart the command prompt, IDEs, or PowerShell windows.
Salesforce CLI Installation on Linux
The Salesforce CLI Installation on Linux is done using a TAR file.
You can use the following table to identify the unversioned TAR file for your system. The manifest URLs display the versioned URLs for the file.
- Once you’ve installed the appropriate file, you need to create an sfdx directory.
- Then unpack the TAR file.
- Now you need to update your path environment variable. This needs to include the Salesforce CLI bin directory.
- Finish the process by running the install script.
You can use the following commands to find out the version installed on your system:
|sfdx – version||The version of CLI installed|
|sfdx plugins||The version of SFDX plugins installed|
|sfdx force – version||The version of the Salesforce API used by CLI|
Learn Salesforce from scratch in this Salesforce tutorial!
Salesforce CLI List of Commands
|force:alias:list||Lists usernames aliases for sfdx|
|force:alias:set||Sets username aliases for sfdx|
|force:apex:class:create||Creates an apex class|
|force:apex:execute||Executes anonymous apex code|
|force:apex:log:get||Fetches a debug log|
|force:apex:log:list||Lists debug logs|
|force:apex:test:report||Displays test results|
|force:apex:test:run||Invokes apex tests|
|force:auth:jwt:grant||Authorizes an org using the jwt flow|
|force:auth:sfdxurl:store||Authorizes an org using an sfdx auth url|
|force:auth:web:login||Authorizes an org using the web login flow|
|force:config:get||Gets conifg var values for the given names|
|force:config:list||List config vars for sfdx|
|force:config:set||Sets config vars for sfdx|
|force:data:bulk:delete||Bulk deletes records from a csv file|
|force:data:bulk:status||Displays the status of a bulk data load job|
|force:data:bulk:upsert||Bulk upserts records from a csv file|
|force:data:record:create||Creates a record|
|force:data:record:delete||Deletes a record|
|force:data:record:get||Displays a record|
|force:data:record:update||Updates a record|
|force:data:soql:query||Executes a soql query|
|force:data:tree:export||Exports data from an org into sObject tree format|
|force:data:tree:import||Imports data into an org using sObject tree API|
|force:doc:commands:display||Displays help for force commands|
|force:doc:commands:list||Lists the force commands|
|force:lightning:app:create||Creates a lightning app|
|force:lightning:component:create||Creates a lightning component|
|force:lightning:event:create||Creates a lightning event|
|force:lightning:interface:create||Creates a lightning interface|
|force:lightning:lint||Lints lightning components|
|force:lightning:test:create||Creates a lightning test|
|force:lightning:test:run||Invokes lightning components tests|
|force:limits:api:display||Displays current org’s limits|
|force:mdapi:convert||Convert metadata api source into the sfdx source format|
|force:mdapi:deploy||Deploys metadata to an org using metadata api|
|force:mdapi:retrieve||Retrieves metadata from an org using metadata api|
|force:org:create||Creates a scratch org|
|force:org:delete||Marks a scratch org for deletion|
|force:org:display||Gets org description|
|force:org:list||Lists all active orgs that you’ve created or authenticated to|
|force:org:open||Opens an org in your browser|
|force:package1:version:create||Creates a new package version in the release org|
|force:package1:version:create:get||Retrieves status of the package upload request|
|force:package1:version:display||Displays details about a package version|
|force:package1:version:list||Lists package versions for the specified package|
|force:package:install||Installs a package in the target org|
|force:package:install:get||Retrieves the status of the package install request|
|force:project:create||Creates a new SFDX project|
|force:project:upgrade||Updates project config files to the latest format|
|force:schema:sobject:describe||Describes an object|
|force:schema:sobject:list||Lists all objects of a type|
|force:source:convert||Converts SFDX source into the metadata API source format|
|force:source:open||Edits a lightning page with a lightning app builder|
|force:source:pull||Pulls source from the scratch org to the project|
|force:source:push||Pushes source to an org from the project|
|force:source:status||Lists local changes and/or changes in a scratch org|
|force:user:password:generate||Generates a password for a scratch org|
|force:user:permset:assign||Assigns a permission set to the admin user of an org|
|force:visualforce:component:create||Creates a visualforce component|
|force:visualforce:page:create||Creates a visualforce page|
Develop your Salesforce skills with this free foundations course!
Salesforce CLI Tips
Here are some useful tips for using Salesforce CLI:
- Autocomplete CLI File Names, Commands, and Parameters
If you partially type a Salesforce CLI command, you can press Tab to complete it automatically. You can also press Tab twice to see all the commands available. This works on file names and parameters as well.
- CLI Runtime Configuration Values
Users are allowed to set CLI runtime configuration value for their current projects or for all projects. There are two types of values that can be set – global and local. Global values will be applied to all the projects on your system while the local values will be applied to a specific project.
- Environment Variable
Environment variables can be set to configure some values that Salesforce CLI tooling uses.
- Support for JSON Responses
Messages that are written to the log file are always in JSON format.
- Log Messages and Log Levels
All log messages written by Salesforce CLI are in the USER_HOME_DIR/.sfdx/sfdx.log file. Log messages are appended to this log file by a CLI invocation.
Get 100% Hike!
Master Most in Demand Skills Now !
Salesforce CLI is useful as it is easy to use, and users don’t need to study it in-depth before using it. We have discussed how you can install it on your operating system along with the system requirements. Salesforce CLI commands are usually associated with SFDX.