Architectural Overview
FunctionReference is an advanced metadata component that binds elastic, serverless compute functions (such as Node.js or Java microservices) to the core Salesforce CRM platform. When enterprise business requirements exceed standard transaction limits—such as complex PDF generation, intensive cryptography, high-volume matrix calculations, or machine learning payload pre-processing—architects offload processing to elastic compute workloads.
FunctionReference provides the declarative gateway that registers the compute function inside the core Salesforce organization. Through this metadata asset, Salesforce administrators and developers can invoke external serverless microservices directly from ApexClass code or declarative Flow actions while inheriting platform identity, mutual TLS authentication, and unified audit logs.
Directory and File Conventions
In Salesforce DX source format (apiVersion 68.0), FunctionReference definitions reside in the functionReferences/ directory.
| Property | Value |
|---|---|
| Metadata Type Name | FunctionReference |
| SFDX Folder | force-app/main/default/functionReferences/ |
| File Suffix | .functionReference-meta.xml |
| XML Root Element | <FunctionReference xmlns="http://soap.sforce.com/2006/04/metadata"> |
Key Metadata Fields
The XML schema for FunctionReference links project containers, function names, and invocation policies:
| Field Name | Field Type | Required | Description |
|---|---|---|---|
masterLabel |
string |
Yes | Human-readable title displayed in Flow Builder and setup consoles. |
developerName |
string |
Yes | Programmatic identifier utilized when querying the function in Apex (functions.Function.get). |
functionName |
string |
Yes | Name of the discrete function handler defined in the serverless project repository. |
project |
string |
Yes | Logical project or service namespace grouping related compute functions. |
description |
string |
No | Architectural summary of the function purpose, expected inputs, and computational limits. |
Note
Apex code invokes registered functions using functions.Function.get('project.developerName') to establish an authenticated, asynchronous execution session.
Declarative XML and Package Manifest Examples
Below is a declarative FunctionReference registering a high-volume pricing calculation microservice:
<?xml version="1.0" encoding="UTF-8"?>
<FunctionReference xmlns="http://soap.sforce.com/2006/04/metadata">
<developerName>Complex_Pricing_Engine</developerName>
<masterLabel>Complex Pricing Engine</masterLabel>
<description>Calculates tier-based CPQ matrix discounts exceeding standard Apex CPU limits.</description>
<functionName>pricingcalculator</functionName>
<project>EnterpriseBillingServices</project>
</FunctionReference>Package Manifest (package.xml)
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Complex_Pricing_Engine</members>
<name>FunctionReference</name>
</types>
<version>68.0</version>
</Package>CLI Retrieval and Deployment Commands
Manage FunctionReference components using the Salesforce CLI:
# Retrieve all function references from your target environment
sf project retrieve start --metadata FunctionReference
# Deploy a specific function reference to your integration sandbox
sf project deploy start --metadata FunctionReference:Complex_Pricing_EngineArchitect Best Practices and Gotchas
- Multi-Pipeline Orchestration: In automated CI/CD environments, always deploy the serverless compute bundle (e.g. via container deployment pipelines) and register the project before deploying
FunctionReferenceto core Salesforce. - Apex Compile Dependencies: Any ApexClass or unit test referencing a function by string name should verify function availability dynamically or handle invocation exceptions gracefully.
- Sandbox Environment Isolation: Ensure sandbox instances reference lower-environment compute endpoints rather than production functions to prevent accidental data contamination during testing.
Tip
Use FunctionReference when complex algorithms threaten to breach the 10-second synchronous Apex CPU limit, shifting heavy computation to elastic infrastructure.
Frequently asked questions
How does FunctionReference connect Salesforce to serverless compute logic?
FunctionReference stores the registered namespace, project binding, and endpoint identifiers needed to invoke functions securely from Apex or Flow.
Can Apex code invoke a function if FunctionReference is not deployed?
No. The Salesforce compute runtime validates the function reference at compile and invocation time, blocking calls to unregistered function names.
How should function deployments be sequenced in multi-tier pipelines?
The compute function code should be built and deployed to the compute infrastructure before deploying the FunctionReference metadata to core Salesforce.
Comments
Questions, corrections and tips are welcome. Comments are GitHub Discussions, so you sign in with GitHub.