getField()
Last updated 20/01/2026
Definition
The
Examples
The following functions demonstrate how you can use the
Read a field value
This code retrieves the value of the FirstName field on the current form page and logs it to the Five Inspector.
const page = five.sender();
const firstNameField = page.getField("FirstName");
const value = firstNameField.getValue();
five.log("First Name:", value);
Validate data in a form field
This code checks the Amount entered on the current form page is positive. If a user enters zero or a negative number, it shows a message in the UI, effectively, it's a simple validation step to prevent invalid amounts from being submitted.
const page = five.sender();
const amountField = page.getField("Amount");
const amount = amountField.getValue();
if (amount <= 0) {
five.showMessage("Amount must be greater than zero");
}
Using getField() with refresh()
This code interacts with a form page to read a value and then refresh the page so that all fields reload their latest data from any updates in the browser.
const page = five.sender();
const statusField = page.getField("Status");
five.log("Current Status:", statusField.getValue());
page.refresh();
// Optional, show a message after refresh()
five.showMessage("Page has been refreshed");
Conditional refresh on a field
This code checks the value of the ApprovalStatus field on the current form page. If the status is Pending, it shows a message in the UI indicating that approval is pending and refreshes the page to ensure the latest data is displayed.
const page = five.sender();
const approvalField = page.getField("ApprovalStatus");
if (approvalField.getValue() === "Pending") {
five.showMessage("Approval is pending, refreshing the page to get the latest updates");
page.refresh()
}