Create a Salesforce Function
Now that you have set up the necessary object permissions in your scratch org, you’re ready to create your first Salesforce Function:
From the command palette run the command:
SFDX: Create Function
- 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 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 the same as the code used in the Context_SalesforceSDK_JS sample.