Skip to main content

form

Last updated 18/12/2025

Examples of using

five.form
. Each Example shows you how to read values on the forms in the stack using the
actionID
and the
fieldID
.

Validating a field value

This example prevents adding line items if no customer ID is selected on the Order Details form.

Validate a line item against a customer
function ValidateLineItem(five: Five, context: any, result: FiveError) : FiveError {
const customerID = five.form.OrderDetails.CustomerID;
if (!customerID) {
return five.createError(result, 'Please select a customer before adding line items');
}

return five.success();
}

Auto-fill shipping details from order details

This example copies the customer address, city, and post code on the Order Details form in the form stack to the current form (Shipping Details).

Populate the shipping details from the order details
function PopulateShippingAddress(five: Five, context: any, result: FiveError) : FiveError {
five.field.Address1 = five.form.OrderDetails.Address1;
five.field.City = five.form.OrderDetails.City;
five.field.PostCode = five.form.OrderDetails.PostCode;
return five.success();
}

Form quantity across forms in the stack validation

The example checks if the value in the Quantity field on the current form is less than the value in the Quantity field on the Sells form in the form stack.

Check the value in the Quantity field on the Sells form in the stack
function CheckBuyQuantity(five: Five, context: any, result: FiveError) : FiveError {
const qty: number = parseInt(five.field.Quantity);
if (qty > five.form.Sells.Quantity) {
return five.createError(result, 'Stock quantity exceeds quantity in this sale');
}

return five.success();
}

Use in a SQL query parameter

This example filters the lookup by the RestaurantKey in the form stack.

note
The RestaurantKey must be included on the form. The key field will be knocked out in the application by Five.

MySQL
Gets the primary key of the restaurant form in the stack
SELECT
AddressKey,
CONCAT(AddressLine1, " ", Suburb) AS Address
FROM
Address
WHERE
RestaurantKey = ?

The parameter would be entered as:

{{five.form.Restaurant.RestaurantKey}}