Skip to content

To help understand how record triggers work, let's examine a typical Save new record operation initiated by a user and walk through what a trigger does.

When the user clicks the Save button, the system captures the object, such as product__v, and event, such as BEFORE_INSERT, which looks up a registry for triggers on the given object and event and executes them in order. The system passes the data entered by the user to the trigger during trigger execution.

BEFORE_INSERT trigger logic can interact with the current record to:

  • Set field values in the current record (Field Default).
  • Get field values entered by the user and validate the value is correct (Field Validation).
  • Cancel the Save operation completely if a field is made required (Conditionally Required field).
  • Use QueryService to find related records by executing Vault Query Service (VQL) to return a set of related records.

After saving the record, the system executes the AFTER_INSERT triggers for the same object.

AFTER_INSERT trigger logic can interact with the current record to:

  • Call RecordService to create related/child records (Create Related Records).
  • Call JobService to start a workflow on the newly created record (Start Workflow).
  • Call JobService to change the state of the current record (Change State).

Since the current record cannot change in the AFTER_INSERT event, most of the business logic in this event interacts with other records through RecordService or performs jobs on the current record that are executed asynchronously in a separate process. Learn more about the order of operations for object field defaults in Vault Help.