• Articles
  • Tutorials
  • Interview Questions

What is Salesforce CLI?

What is Salesforce CLI?

Table of content

Show More

Check out our YouTube video on Salesforce Training:

Video Thumbnail

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 salesforce metadata across various environments, with the help of Salesforce CLI.

Salesforce CLI is based on an open-source framework used in building a command-line interface in Node.js, called Oclif.

SFDX CLI

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.

Salesforce Master 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.

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.

Operating Systems

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.

Node.js

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 from here.
  • Run the .pkg file and answer all prompts.
  • Once the installation is complete, restart the Terminals or IDEs.

Get 100% Hike!

Master Most in Demand Skills Now!

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.

Operating SystemTAR FilesManifest
Linuxsfdx-linux-arm.tar.gzsfdx-linux-arm-buildmanifest
sfdx-linux-arm.tar.xz
sfdx-linux-x64.tar.gzsfdx-linux-x64-buildmanifest
sfdx-linux-x64.tar.xz
  • 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:

CommandDisplay
sfdx – versionThe version of CLI installed
sfdx pluginsThe version of SFDX plugins installed
sfdx force – versionThe version of the Salesforce API used by CLI

Salesforce CLI List of Commands

CommandUse
force:alias:listLists usernames aliases for sfdx
force:alias:setSets username aliases for sfdx
force:apex:class:createCreates an apex class
force:apex:executeExecutes anonymous apex code
force:apex:log:getFetches a debug log
force:apex:log:listLists debug logs
force:apex:test:reportDisplays test results
force:apex:test:runInvokes apex tests
force:auth:jwt:grantAuthorizes an org using the jwt flow
force:auth:sfdxurl:storeAuthorizes an org using an sfdx auth url
force:auth:web:loginAuthorizes an org using the web login flow
force:config:getGets conifg var values for the given names
force:config:listList config vars for sfdx
force:config:setSets config vars for sfdx
force:data:bulk:deleteBulk deletes records from a csv file
force:data:bulk:statusDisplays the status of a bulk data load job
force:data:bulk:upsertBulk upserts records from a csv file
force:data:record:createCreates a record
force:data:record:deleteDeletes a record
force:data:record:getDisplays a record
force:data:record:updateUpdates a record
force:data:soql:queryExecutes a soql query
force:data:tree:exportExports data from an org into sObject tree format
force:data:tree:importImports data into an org using sObject tree API
force:doc:commands:displayDisplays help for force commands
force:doc:commands:listLists the force commands
force:lightning:app:createCreates a lightning app
force:lightning:component:createCreates a lightning component
force:lightning:event:createCreates a lightning event
force:lightning:interface:createCreates a lightning interface
force:lightning:lintLints lightning components
force:lightning:test:createCreates a lightning test
force:lightning:test:runInvokes lightning components tests
force:limits:api:displayDisplays current org’s limits
force:mdapi:convertConvert metadata api source into the sfdx source format
force:mdapi:deployDeploys metadata to an org using metadata api
force:mdapi:retrieveRetrieves metadata from an org using metadata api
force:org:createCreates a scratch org
force:org:deleteMarks a scratch org for deletion
force:org:displayGets org description
force:org:listLists all active orgs that you’ve created or authenticated to
force:org:openOpens an org in your browser
force:package1:version:createCreates a new package version in the release org
force:package1:version:create:getRetrieves status of the package upload request
force:package1:version:displayDisplays details about a package version
force:package1:version:listLists package versions for the specified package
force:package:installInstalls a package in the target org
force:package:install:getRetrieves the status of the package install request
force:project:createCreates a new SFDX project
force:project:upgradeUpdates project config files to the latest format
force:schema:sobject:describeDescribes an object
force:schema:sobject:listLists all objects of a type
force:source:convertConverts SFDX source into the metadata API source format
force:source:openEdits a lightning page with a lightning app builder
force:source:pullPulls source from the scratch org to the project
force:source:pushPushes source to an org from the project
force:source:statusLists local changes and/or changes in a scratch org
force:user:password:generateGenerates a password for a scratch org
force:user:permset:assignAssigns a permission set to the admin user of an org
force:visualforce:component:createCreates a visualforce component
force:visualforce:page:createCreates a visualforce page

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 values 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 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.

Conclusion

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.

Course Schedule

Name Date Details
Salesforce Certification 14 Dec 2024(Sat-Sun) Weekend Batch View Details
21 Dec 2024(Sat-Sun) Weekend Batch
28 Dec 2024(Sat-Sun) Weekend Batch

About the Author

Salesforce Certified Professional

Rahul is a seasoned Salesforce Certified administrator and app builder with 10+ years of experience in many Salesforce technologies, such as Salesforce CRM and business process automation. In his free time, he likes to write and read about the latest technologies.