Skip to main content

Do Create

Last updated 19/03/2026

Overview

The Do Create event is a server-side event that executes when a record is prepared for display in a form. This occurs when a user selects a record from a list and the server retrieves the record and prepares it before sending it to the client.

How it Works

When a record is selected:

  1. The record is retrieved from the database.
  2. The Server prepares the record for the form.
  3. The Do Create event executes.
  4. The record is then displayed in the form.

The event provides access to the record being loaded via the

context
parameter.

Use Cases

  • Logging record access (audit logging)
  • Applying server-side logic before the form is rendered

Example

This function runs whenever a record is opened in a form. It logs the action in the SecurityAudit table, recording a unique ID for the log, the user who opened the record, and the record's data at that moment. Once the log is created, it allows the record to be displayed in the form, ensuring a complete record of who accessed each record and when.

JavaScript
Track record access
function DoCreateRecord(five, context, result) {
const queryResult = five.executeQuery(`
INSERT INTO SecurityAudit ( SecurityAuditKey, SecurityAction, UserKey, Data)
VALUES (?, ?, ?, ?)`, 0, five.uuid(), 'RECORD_RETRIEVED', five.currentUserKey(), JSON.stringify(context));

if (queryResult.isOk() == false) {
return five.createError(queryResult, "Failed to create audit record");
}

return five.success(result);
}