Set Up Your Development Environment
To develop and run Salesforce Functions, install development tools. The tools vary depending on the language you use.
To work with Salesforce Functions, install these tools:
- Node.js 14 or higher to develop functions that use JavaScript or TypeScript. Use
npm
version 6.13.4 or higher. - OpenJDK 8 or higher and Apache Maven 3.6.3 or higher to develop functions that use Java.
- Git CLI or GUI client to track changes in your function code. See Set up Git.
- (Optional) To push changes to GitHub, create a github.com account.
- (Optional) To save your function log output to a log drain, set up a log drain receiver or sign up with a service that can accept log drains. See Function Logging.
Salesforce CLI is a bundle of two executables: sf
and sfdx
.
The sf
executable is designed to eventually work across all Salesforce clouds. It contains all the Salesforce Functions-related commands and a handful of Salesforce Platform commands.
The sfdx
executable is focused on Salesforce Platform. For now, use both executables to create and deploy Salesforce Functions, as shown in the examples in this guide.
-
To get both executables, install Salesforce CLI.
-
Update to the latest version.
Run the update command even if you previously installed Salesforce CLI. Check the Salesforce CLI Release Notes for the most recent CLI versions.
-
Confirm you have
sfdx
CLI version 7.176 or later.Example output:
-
Run
sf version
and confirm you have version 1.53 or later.Example output:
-
Run
sf plugins --core
and view the list of all installed plug-ins. Make sure the Salesforce Functions plugin is installed.The output looks like this:
If your versions are still outdated, then completely uninstall the Salesforce CLI and follow the previous instructions to reinstall.
To develop a function using TypeScript or Java, you need the Salesforce SDK.
When you generate a function with sf generate function
, these dependencies appear in the example code.
See Salesforce SDK for Node.js Functions for more on using Node.js.
See Salesforce SDK for Java Functions for more on using Java.
If you use Visual Studio Code, install Salesforce Extensions for Visual Studio Code, which includes support for working with Salesforce Functions using the Command Palette.
To install, browse for the extension within Visual Studio Code, or go to Salesforce Extensions for Visual Studio Code and click Install the Salesforce Extensions.