---
schema_version: "1"
id: 15991ae3b257e4afc8f0776e12a0113c61fa8870ac6d3ef5bb6a543dbcc2ec8e
title: FunctionCallback Interface
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_interface_functions_FunctionCallback.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_functions_FunctionCallback.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 494e7c7eba535ff735cd6329369801e0c9a0275ea68b21092c1da41e4765676a
description: Represents the callback Salesforce calls when an asynchronous, queued Function invocation has completed.Called when an asynchronous Function invocation has completed.
---
# FunctionCallback Interface

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

## Namespace

[functions](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_functions.htm "The Functions namespace provides classes and methods used to invoke and manage Salesforce Functions.")

## Usage

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

- **[FunctionCallback Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_functions_FunctionCallback.htm#apex_functions_FunctionCallback_methods)**
- **[FunctionCallback Example Implementation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_functions_FunctionCallback.htm#apex_interface_functions_FunctionCallback_Example)**

## FunctionCallback Methods

The following are methods for FunctionCallback.

- **[handleResponse(var1)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_functions_FunctionCallback.htm#apex_functions_FunctionCallback_handleResponse)**  
    Called when an asynchronous Function invocation has completed.

### handleResponse(var1)

Called when an asynchronous Function invocation has completed.

#### Signature

public void handleResponse(functions.FunctionInvocation var1)

#### Parameters

- **var1**: Type: [functions.FunctionInvocation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_functions_FunctionInvocation.htm#apex_interface_functions_FunctionInvocation "Use FunctionInvocation to get the status and results of a synchronous or asynchronous Function invocation.") 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.

public with sharing class MyCallback
  implements functions.FunctionCallback {
    public void handleResponse(functions.FunctionInvocation result) {
      // Handle result of function invocation
      String jsonResponse = result.getResponse();
      System.debug('Got response ' + jsonResponse);
      JSONParser parser = JSON.createParser(jsonResponse);
      // Process JSON using your own data class...
    }
}

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

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