Skip to main content

getField()

Last updated 20/01/2026

Definition

The

is a function on the

FormPage
object that retrieves a specific field from a FormPage by its unique field identifier.

Examples

The following functions demonstrate how you can use the

getField()
function on the
FormPage
object.

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.

JavaScript
Retrieve and log FirstName field
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.

JavaScript
Retrieve an amount value and use it in logic
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.

JavaScript
Log the Status field value and refresh the page
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.

JavaScript
Check pending approval and refresh the page
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()
}