Function Callback

Updated 1 month ago by Copado Solutions

In the article Building a Function, we talked about the Callback section, where you can define an action to be executed once the function has run. This action can be an Apex class or a Salesforce flow. 

In this article, we will describe the callback functionality in more detail.

When you execute a function, Copado creates a Result record that shows the current progress of the function execution. The backend sends a platform event to update the status of the function execution in real time. This platform event also triggers the class or flow defined as function callback.

The class or flow callback receives the result status of the function execution, the Result record and the Function record:

Global class MyCallback implements copado.MCCallback {
Global void execute(copado__Function__c function, copado__Result__c result, String status) {
if(status == 'Failed') {
// handle Error
} else if(status == 'Success') {
// handle Success
} else {
// handle In progress if necessary

If you want to subscribe to the platform event, the API name of the MC Result event is copado__MC_Result__e. When receiving the platform event, check if Is Finished equals True and Is Success equals True to confirm the function execution completed successfully. If Is Finished equals True and Is Success equals False, it means that the function execution failed.

Event Screen

Additional Considerations for Flow Callbacks

If you are configuring a flow to be used as a callback, you can create three input variables to collect the status, Function and Result record information which are optional. You should configure these variables as follows:

Result Status

Result Record

Function Record

API Name




Data Type




Availability Outside the Flow

Available for input

Available for input

Available for input

This way, your flow can interact with these variables as needed (e.g., checking if the status is Success or Failed).

How did we do?