The dedicated set of commands that simplifies the development strategies and automates the building process while ascertaining the work associated with the Salesforce organization is termed as Salesforce CLI. Salesforce CLI supports and speeds up the development process for both developers and admins at the same time and it sets that statements are considered powerful for the development of the line interface according to the rules included with the Salesforce organization.
To use the Salesforce CLI, one needs to use a terminal to enter commands and interact with the program. This would be Windows Terminal on Windows and it’s simply called Terminal on a Mac. Interacting with a text-based interface is very different from a graphical one and instead of clicking on buttons and inputs, one needs to type out the commands for what one wishes to achieve, which are then processed and run by the program in the platform. Thus, these tasks get done quicker compared to a graphical interface, and it allows for the easy automation of any repetitive tasks. However, without the visual prompts, there is a much steeper learning curve.
Uses of the Salesforce CLI
Let us look into some real-life use cases and scenarios where we could use the CLI to help increase our efficiency in business platforms:
1. Retrieve and Deploy Metadata
Being a Salesforce Consultant, after completing a project involving the creation of a flow embedded in the utility bar, then the intention will be to allow the end users to quickly raise cases and requests for help. Testing of users was a great success and it was deployed from the testing environment to production using changesets. Rather than redevelop the same feature twice, one can decide to use the Salesforce CLI to kickstart the feature by deploying the known tried-and-tested solution from the previous organization, before meeting the client’s specific needs.
2. Import and Export Data
When one has a UAT environment running on a partial copy sandbox and then they build a great set of test accounts and contacts which they wish to move from their partial copy into several new development sandboxes. If the sandbox types don’t match, one can’t just create a new sandbox using the UAT environment as our source. Then it requires exporting the data out and importing it to the development sandboxes, but then one either needs to work with external Ids or do VLOOKUPS (or similar) within Excel every time and this is not even scalable.
3. Sandbox Creation
If one follows the previous scenario then one has only populated a single sandbox, when in fact they want several. Logging into the production environment and creating half a dozen sandboxes seems like a tedious task now, but that one has unlocked the power of the CLI. The Salesforce CLI contains the force:org:create command which is commonly used to create scratch organization, but also it is used to create sandboxes for all. They require us to use many parameters that are mostly defined as key value pairs within the command.