Solutions and Sample Code

Get help using Functions to solve specific problems.

Our library of solutions covers all aspects of creating and working with Salesforce Functions. Many solutions include links to sample code that you can use as a starting point for your Function development.

Sample Code Repositories

Check out these GitHub repositories, which contain Functions recipes and the eCars sample app.

Access Org Data from a Function

Use the Salesforce SDKs, along with other standard Salesforce APIs, to access org resources.

Manage Transactions in a Function

Functions, unlike Apex, don't automatically handle data transactions for you. Transactions ensure that all related data changes are made at the same time and that they can be undone if necessary. To manage transactions in a Function, use the UnitOfWork SDK class.

Develop JavaScript and TypeScript Functions

Use JavaScript or TypeScript along with your favorite Node frameworks to build a Function that can be invoked from your org.

Develop Java Functions

Use Java and your favorite Java frameworks to build a Function that can be invoked from your org.

Migrate Apex Code to Functions

Do you have Apex code that is hitting Apex compute limits? Transition your Apex code to a Function using patterns and best practices, and take advantage of elastic auto-scaling in Salesforce Functions compute environments.

Run and Debug Functions Locally

Before you deploy your Function, you can run and debug it locally.

Test Functions

Learn how to integrate your Function code and Function invocation code in your testing pipeline.

Understand Functions and Application Lifecycle Management

Like any Salesforce org custom development, you need to manage how and where Functions are tested and deployed. Functions compute environments are tied to orgs, helping you avoid deploying an in-development Function to a production org.

Deploy Functions to a Compute Environment

Before a Function can be invoked from a Salesforce org, it must be deployed to a Salesforce Functions compute environment associated with the org.

  • Overview Understanding Functions projects and compute environments.
  • Developer Guide: Deploy a Function Steps for connecting an org with Functions, creating compute environments, and deploying Function projects to compute environments.

Invoke Functions from Your Org

Salesforce makes it easy to invoke a deployed Function from your org, using Salesforce features you're already familiar with, like Apex. You can invoke a Function from your org synchronously or asynchronously as easily as calling an Apex method.

Configure Permission Sets for Functions

When invoked, Functions use specific permission sets for data access. Understand what permissions you can set, which permission sets to use, and what user role runs the Functions.