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.
DeployCallback Interface
Namespace
Usage
You must provide a callback class for the asynchronous deployment of custom metadata through Apex. This class must implement the Metadata.DeployCallback interface.
Salesforce calls your DeployCallback.handleResult() method asynchronously once the queued deployment completes. Because the callback is called as asynchronous Apex after deployment, there may be a brief period where the deploy has completed, but your callback has not been called yet.
DeployCallback Methods
The following are methods for DeployCallback.
handleResult(var1, var2)
Signature
public void handleResult(Metadata.DeployResult var1, Metadata.DeployCallbackContext var2)
Parameters
-
var1:
Type: Metadata.DeployResult
The results of the asynchronous deployment.
-
var2:
Type: Metadata.DeployCallbackContext
The context for the queued asynchronous deployment job.
Return Value
Type: void
DeployCallback Example Implementation
This is an example implementation of the Metadata.DeployCallback interface.
1public class MyCallback implements Metadata.DeployCallback {
2 public void handleResult(Metadata.DeployResult result,
3 Metadata.DeployCallbackContext context) {
4 if (result.status == Metadata.DeployStatus.Succeeded) {
5 // Deployment was successful
6 } else {
7 // Deployment was not successful
8 }
9 }
10}The following example uses this implementation for a deployment.
1// Setup callback and deploy
2MyCallback callback = new MyCallback();
3Metadata.Operations.enqueueDeployment(mdContainer, callback);