Create a Salesforce Function
You're ready to create your first Function. Run this command in the project root directory:
-n functionNamethe name of the Function. Names must start with a letter and contain only lowercase letters and numbers.
-l languagethe programming language to use.
Your project now contains the basic scaffolding that contains supporting metadata and a default boilerplate code for your first Function. Now let's take a closer look at the files that were created:
- A new directory named after your Function name is created, along with default configuration files.
project.tomlfile that contains Function metadata information. See Developer Guide: Function Metadata TOML Files for more details.
index.jsthat contains some rudimentary Function code. This file is your primary source code file. It's preconfigured with an entry point method that has parameters used to pass payload data to the Function and to communicate with the invoking org The default function in
index.jslogs the received payload, issues a query for Account data, and logs the query results.
The function parameters are:
|event||An Event object that describes the triggering event and contains event data. This parameter is also sometimes called the 'payload.'|
|context||Salesforce org context for reading from and writing to Salesforce. The context is pre-configured to be authenticated to the invoking org.|
|logger||Salesforce logger for the function.|
name field of the payload:
This code is from Context_SalesforceSDK_JS sample.