Introduction to the Force Command Line Interface (CLI)

Salesforce provides a CLI tool that adds a useful bow to the developers and administrators armoury.

  • Provides different tooling options to the Salesforce developer or administrator
  • Output is easily captured and available (run and query and put results in a text file)
  • Command line operation can allow chaining with other tools with scripted and repeatable operations.

Note that this tool is different to the CLI tool used by dataloader.

Download from here: https://developer.salesforce.com/tools/forcecl

It is available in different flavours for Windows, Mac and Linux.

In Windows case, the download is an exe, so just copy it somewhere and then navigate to it with a command prompt.  Run ‘force’ to get the help list of commands:

Some Examples:

Login:

> force login

This launches browser where you can type creds and allow cli access.  You can also use -u and -p flags to provide username and password (with security token)

Run a Query:

> force query “select name from account”

View a Record:

> force record get account 0010Y00000ULl7XQAT

Update a Record:

> force record update account 0010Y00000ULl7XQAT name:”University of Boulder”

List fields on Object:

>force field list account

Export metadata to file system:

>force export

And more… (Will try and add to this list as we work through it… let us know your favourites)

 

This entry was posted in BrainDump and tagged , . Bookmark the permalink.

Leave a Reply