Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

FunctionCallback Interface

Represents the callback Salesforce calls when an asynchronous, queued Function invocation has completed.

Namespace

functions

Usage

When invoking Functions asynchronously via Function.invoke(payload, callback), you provide your own class that implements FunctionCallback.

FunctionCallback Methods

The following are methods for FunctionCallback.

handleResponse(var1)

Called when an asynchronous Function invocation has completed.

Signature

public void handleResponse(functions.FunctionInvocation var1)

Parameters

Return Value

Type: void

FunctionCallback Example Implementation

This is an example implementation of the functions.FunctionCallback interface.

1public class MyCallback
2  implements functions.FunctionCallback {
3    public void handleResponse(functions.FunctionInvocation result) {
4      // Handle result of function invocation
5      String jsonResponse = result.getResponse();
6      System.debug('Got response ' + jsonResponse);
7      JSONParser parser = JSON.createParser(jsonResponse);
8      // Process JSON using your own data class...
9    }
10}

The following example uses this implementation when invoking a Function asynchronously:

1myFunction.invoke('{ "accountName" : "Acct", "contactName" : "MyContact", "opportunityName" : "Oppty" }', new MyCallback());