**Source URL:** https://limited.veevavault.dev/vault-sdk/entry-points/triggers/doctype-triggers/about-doctype-trigger-events

# About Doctype Trigger Events

Doctype trigger events specify the type of data change that causes this trigger fire. For example, triggers can fire before or after create, update, and delete events. Create events are called `INSERT` in Vault Java SDK.

Available doctype trigger events:

*   `BEFORE_INSERT`
*   `AFTER_INSERT`
*   `BEFORE_UPDATE`
*   `AFTER_UPDATE`
*   `BEFORE_DELETE`
*   `AFTER_DELETE`

When reading about events in documentation, a `BEFORE` event refers to any event which includes `BEFORE`, for example, `BEFORE_INSERT`, `BEFORE_UPDATE`, and `BEFORE_DELETE`. Similarly, an UPDATE event refers to any event which includes `UPDATE`, for example, both `BEFORE_UPDATE` and `AFTER_UPDATE`.

Certain information about a document is only available to get or set during certain events. For example, you cannot set document metadata during a `DELETE` event, and you cannot get data during an `INSERT` event. Understanding [data availability](/vault-sdk/entry-points/triggers/data-availability/) can help you pick the right event for your custom logic.

## INSERT

`INSERT` events are create events, and fire whenever a new document or document version is created. For example, uploading a new version of an existing document.

You can also develop doctype triggers with different logic depending on how the new document version was created. For example, developers can detect if the `INSERT` event for a new document version was the result of a *Create Draft* action, and update their business logic accordingly. Doctype triggers can differentiate between the following types of `INSERT` events:

### Create Draft

If a new document version was inserted with the [Create Draft](https://platform.veevavault.help/en/lr/1560) option, the `DocumentTypeCreateDraftExecutionContext` interface is available. Users can also create draft documents with [Vault API](/vault-api/api-reference/26.1/documents/update-documents/create-single-document-version/).

You can use this interface to determine if the new draft came from:

*   `LATEST_CONTENT`: The new draft version was created from an existing document in Vault. This did not require uploading a file. This is analogous to the *Copy file from current version* option in the *Create Draft* UI.
*   `UPLOADED_CONTENT`: The new draft version was created by uploading a document source file. This is analogous to the *Upload a new file* option in the *Create Draft* UI.

### Check In

If the new document version was inserted by a [check in](https://platform.veevavault.help/en/lr/162/#how-to-check-out-documents) of any kind (such as [Collaborative Authoring](https://platform.veevavault.help/en/lr/56842) check-in), the `DocumentTypeCheckInExecutionContext` interface is available. This context allows developers to customize doctype trigger logic for document versions created by a document check-in.

## UPDATE

`UPDATE` doctype triggers occur whenever data on the same document version changes.

<Aside type="note" title="Note">
`UPDATE` doctype triggers only update the latest version of a document. This means `UPDATE` events only fire on triggers scoped to the [`DOCUMENT_VERSION`](/vault-sdk/entry-points/triggers/doctype-triggers/about-doctype-trigger-event-levels/#DOCUMENT_VERSION) level.
</Aside>

A change to a document that causes a new document version is considered an `INSERT` event, not an `UPDATE` event. For example, uploading a new version of an existing document is an `INSERT` event, while updating the `archive__v` field on an existing document version is an `UPDATE` event.

## DELETE

`DELETE` doctype triggers fire on delete events, either deleting an entire document or deleting a single version. When an entire document is deleted, Vault fires `DOCUMENT` triggers, but does not fire triggers for every subsequent deleted version.

If a user deletes a document version, Vault fires `DELETE` triggers scoped to `DOCUMENT_VERSION`. If that version is the last remaining version for the document, this instructs Vault to delete the entire document, which also fires `DELETE` triggers scoped to `DOCUMENT`.

---

**Previous:** [About Doctype Trigger Event Levels](/vault-sdk/entry-points/triggers/doctype-triggers/about-doctype-trigger-event-levels)  
**Next:** [Role Triggers](/vault-sdk/entry-points/triggers/role-triggers)