Salesforce CLI, the code extension plugin, and the Data Custom Code Python SDK work together as your local toolchain for Code Extension. Use this setup to develop and test custom chunking functions locally against a sandbox and then deploy them to Data 360 for execution.
| Edition Table |
|---|
| Available in: Developer, Enterprise, Performance, and Unlimited Editions. See Data 360 edition availability. |
| User Permissions Needed | |
|---|---|
| To set up and use the Salesforce CLI for custom function development: | Permission set: <ul><li>Data Cloud Architect</li></ul> |
Prerequisites
- Local machine: Use macOS, Linux, or Windows; Python 3.11; and Azul Zulu OpenJDK 17.x; Docker Desktop (enable the WSL 2 backend for Dev Containers and other container workflows. See Docker Desktop on Windows).
- Data 360: Sandbox or org access with appropriate permission sets. See Create a Data 360 Sandbox. Enable Code Extension in Feature Manager. See Enable Data 360 Features in Feature Manager.
Steps to Set Up Salesforce CLI for Custom Functions
-
Install Salesforce CLI version
2.130.9or later. See Install Salesforce CLI. -
Confirm that your Salesforce CLI version is
2.130.9or later:sf versionIf you have an earlier version, update Salesforce CLI. See Update Salesforce CLI, and then run
sf versionto confirm. -
On Windows, install Node.js LTS and verify the installation.
node --version npm --version -
Install the code extension plugin.
sf plugins install @salesforce/plugin-data-code-extension -
Make sure the installed code extension plugin version is
0.1.5or later. If you have an earlier version, update the plugin to the latest available version.sf plugins sf plugins update -
Install the Data Custom Code Python SDK.
macOS and Linux
python3.11 -m pip install salesforce-data-customcodeWindows
py -3.11 -m pip install salesforce-data-customcode -
(Optional) Upgrade the Data Custom Code Python SDK to the latest available version.
macOS and Linux
python3.11 -m pip install --upgrade salesforce-data-customcodeWindows
py -3.11 -m pip install --upgrade salesforce-data-customcode -
Confirm the SDK installation.
- macOS and Linux:
python3.11 -m pip show salesforce-data-customcode - Windows:
py -3.11 -m pip show salesforce-data-customcode
- macOS and Linux:
-
Log in to your org. From a terminal, run one of the commands with the flags for your org type. Salesforce CLI opens your default browser for Salesforce sign-in. After you sign in, the CLI saves the session on your computer.
-
Production or Developer Edition
sf org login web --alias <myorg> -
Sandbox
sf org login web --alias <mysandbox> --instance-url https://test.salesforce.com -
Custom domain
sf org login web --alias <myorg> --instance-url https://mycompany.my.salesforce.com
-
-
After you sign in, confirm which orgs the CLI is connected to and which
aliasyou must use for code extension commands.sf org list sf org display --target-org <myorg>For example, run
sf org display --target-org myorgto display the connection status of your org aliasmyorg.note: Running the
sf org logincommand is a one-time setup per environment or profile. Rerun this command only if your credentials or environment details change, or if you want to set up a new profile. -
Create a code extension function package.
sf data-code-extension function init --package-dir <PACKAGE_DIR>Example:
sf data-code-extension function init --package-dir <my_package>Replace
<my_package>with the directory name for your project, for example,my_function_package.
The command sets up the directory structure, configuration files, and dependencies for writing, testing, and deploying a custom chunking function.
```text
my_package/
├── requirements.txt
├── requirements-dev.txt
├── Dockerfile.dependencies
├── build_native_dependencies.sh
├── payload/
│ ├── config.json
│ └── entrypoint.py
├── .datacustomcode_proj/
│ └── sdk_config.json
├── .devcontainer/
│ └── devcontainer.json
└── README.md
```
Here's a summary of the directories and files in the package.
| Directory or File | Description |
|---|---|
Dockerfile.dependencies |
Used to build dependency layers for packaging workflows. |
build_native_dependencies.sh |
Helper script to build native Python dependencies when needed. |
requirements.txt |
Lists the Python packages your function needs for deployment. |
requirements-dev.txt |
Python packages for local development and testing only. Don't modify this file. |
payload/ |
Contains the function and configuration that the CLI deploys to Data 360. |
payload/config.json |
The configuration manifest for a Data 360 code extension package. It defines how the function will be executed and what resources it needs. |
payload/entrypoint.py |
Main Python file where you implement your chunking function, for example, function(request, runtime). |
.datacustomcode_proj/sdk_config.json |
Project metadata generated by the CLI, for example, type: "function". |
.devcontainer/devcontainer.json |
Visual Studio Code Dev Container configuration for a consistent local environment. |
README.md |
Package overview, setup notes, and how to run samples in a container or locally. |