event()
Last updated 13/01/2026
Definition
The event() is a function on the
Form
object that returns the ID of the event that caused the form logic to run, such as OnShow
.
Examples
The following functions demonstrate how you can use the
event()
function on the Form
object.
Log which event triggered the form
This code reads the event that caused the form logic to execute.
Read the event that caused the form logic to execute
const form = getCurrentForm();
const eventID = form.event():
five.log("Form logic triggered by:", eventID);
Run code when the form is shown
This code runs when the form is shown and gets the value in the Status field and logs the result to the Five Inspector.
Gets the Status field value when the form is shown
const form = getCurrentForm();
if (form.event() === "OnShow") {
five.log("Form has just been shown");
// Example get initial value from form field and log it to the Five Inspector
const value = form.getPage("General").getField("Status").getValue();
five.log(value);
}
Combine with actionID()
This code runs when the form is shown and initializes the form by getting a form field value. Specifically, it detects that the Customers form has just been shown and then automatically gets the value in the Name field and logs it to the Five Inspector.
Gets the name value while verifying we are showing the Customers form
const form = getCurrentForm();
if (form.actionID() === "Customers" && form.event() === "OnShow") {
five.log("Customers form shown");
const value = form.getPage("General").getField("Name").getValue();
five.log(value);
}