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

var1
Type: functions.FunctionInvocation
The result parameter contains JSON response information and error information.

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());