These event formulas run in the current object context. The documented Argument_... variables are available as named arguments; object entry values can also be available as formula variables.
OnAfterSave runs after a save attempt. Its Result is ignored. It can also run after an unsuccessful database save, so a formula must not assume that the record was saved successfully. Argument_DataID identifies the current record. Argument_ChangedEntryList can be available at runtime as a comma-separated list of changed entries, but is not declared in the editor.
OnBeforeSave runs before DBForm data is saved and is also available to custom ReasonForms. Argument_DataID identifies the record and Argument_ChangedEntryList is the comma-separated list of changed entries. Despite the NeedResult=False metadata, the result controls saving: return True or DB_TRUE to block the save; any other value allows it to continue.
OnDataChange runs for object data changes with Argument_DataID and Argument_ChangedEntryList. Its Result is ignored. Use it for side effects that must react to the changed-entry list.
OnBeforeDeleteRecord runs on the common object record-deletion path. Argument_DataID identifies the record; it is -1 while deleting records with a null key. Return False to block the standard deletion. Flex-record-item deletion and the legacy web object tree's direct SQL deletion bypass this event.
OnNewRecord runs when a new object record is created. Its Result is ignored. The runtime context can include Argument_DataID, Argument_ChangedEntryList and DBForm parser variables; these values are not declared as named arguments in the event editor.
OnGetNextPrimaryKey must return the next primary key as Result. A value greater than zero is used as the new identifier. A value of zero or less leaves key generation to the object's standard key handling. This event has no declared arguments.
OnGetRecordIsVisible determines whether a record can be displayed. Argument_DataID identifies the record. Return True to allow further visibility checks. False, Null or a script error hides the record. Object and record permissions are also applied, so a True result cannot make a record visible when access rights hide it.
OnGetRecordIsReadOnly determines whether a record is read-only. Argument_DataID and the current record's entry values are available to the formula. Return True to make the record read-only. False, Null or a script error does not itself prevent editing, but application mode, object settings and user permissions can still make the record read-only.
OnGetObjectIcon customizes an object-tree icon. Argument_ObjectID identifies the object and Argument_DataID identifies the record; Argument_DataID can be -1 for an object or folder node without a record. Current record entry values can also be available. The text returned in Result must be the name of a registered icon. If the formula fails or the name is unknown, the default icon is retained.
OnGetObjectTextColor customizes an object-tree node's text color. It receives Argument_ObjectID, Argument_DataID and, where applicable, the current record's entry values. Return the color as an integer Delphi TColor value. A script error or a result that cannot be converted to an integer retains the default text color.
OnGetColumnColor returns the column background as a Delphi TColor. The common and desktop paths populate Argument_ObjectID, Argument_ColIndex, numeric Argument_EntryID, Argument_EntryName and Argument_CurColor. The current implementations always pass Null as Argument_CurColor. On web, Argument_EntryID incorrectly receives the entry name instead of its numeric ID; use Argument_EntryName when the formula must work on both platforms.
OnGetStatusBarText returns the text displayed in the object grid status bar. Argument_CurEntry, Argument_CellValue and Argument_SelectedIDCount are populated. The declared Argument_Col and Argument_Row values are not: the runtime writes misspelled Argmument_Col and Argmument_Row variables instead. Do not rely on either coordinate name until the implementation is corrected.
Selection statistics are available as EntryName.Min, EntryName.Max, EntryName.Sum, EntryName.Avg, EntryName.Count and EntryName.CountNotNull. When multiple records are selected, these values describe the selection.
OnGetMaxCellLineCount sets the maximum number of text lines displayed in an object grid cell. It has no event-specific arguments. Return the required line count as an integer. Without a valid formula, the grid's configured MaxCellLineCount value is used; if execution of a valid formula fails, the calculated value is 0.
OnGetFlexObjectRefFilterName selects the global filter used to populate a Flex ObjectRef entry. The object-level event is used when the owning DBForm component has no valid formula of the same name. For a current Flex record item it receives Argument_FlexDataID, Argument_FlexRecordID, Argument_FlexEntryName and Argument_EntryName. Return an existing global filter name in Result; return Null to apply no custom filter. A non-null name that cannot be found raises an error.
OnInitDBTable runs in the object context during object initialization and can also be invoked by the global object-init script pass. It has no event-specific arguments, and formulas should be idempotent because more than one initialization route can reach it. Although its metadata says NeedResult=True, the calculated result is discarded and has no effect. A formula error marks the object as having problems when called from the object's own initialization path.
OnDoubleClickOverview runs when the user double-clicks an overview record; its Result is ignored. On desktop and web it can use Argument_DataID, Argument_SelectedIDStr, Argument_SelectedIDs and Argument_SelectedIDCount.
OnNewRecordOverview runs when a new record is created from the desktop object overview; its Result is ignored. The same overview selection values and object entry variables can be available at runtime. The current web grid does not have a connected new-record event.
OnDeleteRecordOverview receives Argument_DataID, Argument_SelectedIDStr, Argument_SelectedIDs and Argument_SelectedIDCount. On desktop, returning Boolean False or the exact text "Skip_Standard_Delete" blocks standard deletion. The current web grid recognizes only the exact text; Boolean False does not block it. The legacy web object tree and fast recursive deletion execute the formula but ignore its result.
// Hide archived records.
Result := Status <> "Archived";
// Make locked records read-only.
Result := Locked = True;
// Display at most three lines of text in an object-grid cell.
Result := 3;
// Select an existing global filter for a Flex ObjectRef entry.
Result := "ActiveProducts";
// Block saving when a required value is missing.
Result := RequiredEntry = Null;
// Set an object-grid column to red (Delphi TColor).
Result := 255;
// Display selection information without using the misspelled coordinates.
Result := "Selected records: " + VarToStr(Argument_SelectedIDCount);