# Callback functions

Source: https://developer.avalara.com/products/ecm/integration-guides/document-management/ekr5210536156482/

Guide: Exemption Certificate Management (ECM)

# Callback functions

Learn about the available callback functions for handling events in the certificate generation process.

Function

Description

`onUpload`

Called when a document is uploaded. Access the generated certificate ID with `GenCert.certificateIds`.

We recommend adding the `onUpload` function. If you don't, your customer won't know what to do after the certificate has been uploaded.

**Example**

```
GenCert.init(document.getElementById("form_container"), {
  ship_zone: "Alabama",
  customer_number: "cc00001154",
  onCertSuccess: function() {
    window.alert("Successful creation");
  },
  onUpload: function() {
    GenCert.hide();
  }
});
GenCert.show();
```

`onCertSuccess`

Can be overridden to perform a customized action, such as user navigation after a certificate is successfully created. When the certificate is successfully submitted, access the generated certificate ID using `GenCert.certificateIds`.

`onCancel`

User cancels the certificate generation process. Used to reinitialize `GenCert` or provide user navigation.

`onManualSubmit`

Used to reinitialize `GenCert` or navigate the user elsewhere. Reinitialization occurs when the nexus (exemption matrix) is set to manually collect a document. The user can upload a form when this happens.

`onInit`

Called when the plugin is first initialized.

`beforeShow`

Called before the form appears.

`afterShow`

Called after the form appears.

`beforeValidate`

Called before the form is validated.

`onValidateSuccess`

Called after the form validation is successful. But, before form submission.

`onValidateFailure`

Called after the form validation fails.