Skip to main content

getValue()

Last updated 13/01/2026

Definition

The

is a function on the

Form
object that reads or retrieves the current value of a field on the form. When multiple pages are on a form,
getValue()
will find the first unique identifier for a field.

It is recommended to use

when you have the same field ID for multiple fields on the one form which has multiple pages.

Examples

The following functions demonstrate how you can use the

getValue()
function on the
Form
object.

Read and log a form field value

This code reads and logs the value in the MeasurementType field on the current form to the Five Inspector.

JavaScript
Read and log the MeasurementType field's value to the Five Inspector
const form = getCurrentForm();

// Get the value in the MeasurementType field
const measurementType = form.getValue("MeasurementType");

// Could output: "Length", "Weight", etc
five.log(measurementType);

Conditional behaviour

This code gets the current form, reads the value of the MeasurementType field, and checks whether it is Length. Based on the check, it logs a message in the UI indicating whether the value is Length or not.

JavaScript
Conditional behavior depending on the MeasurementType field's value
const form = getCurrentForm();

const measurementType = form.getValue(MeasurementType);

if (measurementType === "Length") {
five.message("This measurement is a length");
}

Multiple field values together

This code gets the current form, reads two values from the form, checks that both values exist, calculates an area and logs the result to the Five Inspector.

JavaScript
Calculates an area using values from two fields on the current form
const form = getCurrentForm();

const width = form.getValue("Width");
const height = form.getValue("Height");

if (width && height) {
const area = width * height;
five.log("Area:", area);
}