FunctionInvocation Interface

Use FunctionInvocation to get the status and results of a synchronous or asynchronous Function invocation.

functions

The results of a Function invocation are passed back via FunctionInvocation. Use this instance to determine if the invocation was successful, and any results from the Function invocation.

You can also implement your own FunctionInvocation interface if you run Apex tests with your Function invocation code. Your test code can create and use your own FunctionInvocation instance in place of using the results from a call to Function.invoke().

The following are methods for FunctionInvocation.

  • getError()

    Returns error information for a Function invocation.

  • getInvocationId()

    Returns the invocation ID of the Function invocation.

  • getResponse()

    Returns the response string of the Function invocation.

  • getStatus()

    Returns the status of the Function invocation.

Returns error information for a Function invocation.

public functions.FunctionInvocationError getError()

Type: functions.FunctionInvocationError

Contains a FunctionInvocationError instance that you can use to get information about any invocation errors. If the Function was invoked successfully, the returned instance is null.

Returns the invocation ID of the Function invocation.

public String getInvocationId()

Type: String

This ID is available after a call to either the synchronous or asynchronous Function.invoke() methods. For asynchronous invocations, this ID can be used to check the status of the queued invocation.

Returns the response string of the Function invocation.

public String getResponse()

Type: String

The response string is the raw request JSON response, which can be parsed using the JSONParser Class.

Returns the status of the Function invocation.

public functions.FunctionInvocationStatus getStatus()

Type: functions.FunctionInvocationStatus

The result of the invocation, such as FunctionInvocationStatus.SUCCESS or FunctionInvocationStatus.ERROR.

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

The following example tests the implementation: