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_INSERTAFTER_INSERTBEFORE_UPDATEAFTER_UPDATEBEFORE_DELETEAFTER_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 can help you pick the right event for your custom logic.
INSERT
Section link for INSERTINSERT 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
Section link for Create DraftIf a new document version was inserted with the Create DraftDocumentTypeCreateDraftExecutionContext interface is available. Users can also create draft documents with Vault API.
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
Section link for Check InIf the new document version was inserted by a check inDocumentTypeCheckInExecutionContext interface is available. This context allows developers to customize doctype trigger logic for document versions created by a document check-in.
UPDATE
Section link for UPDATEUPDATE doctype triggers occur whenever data on the same document version changes.
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
Section link for DELETEDELETE 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.