Skip to main content

field

Last updated 10/12/2025

Examples of using

five.field
. Each example shows how you read or write values on the current form using the
fieldID
.

Reading a field value

This example returns the value stored in the Quantity field on the current form.

JavaScript
Read the Quantity field
let qty = five.field.Quantity;

Writing a value to a field

This example sets the Total field on the current form to 100.

JavaScript
Write to the Total field
five.field.Total = 100

Using a field in a function

This example checks the value stored in the Quantity field, if greater than 1000, it sets the Fee field to 25, otherwise to 10.

JavaScript
Calculate the Fee field
function (five, context, result) {
if (five.field.Quantity > 1000) {
five.field.Fee = 25;
} else {
five.field.Fee = 10;
}

return five.success(result);
}

Updating a field based on two other fields

This example uses the values stored in the Quantity and Price fields to set the total in the Total field.

JavaScript
Updating the Total field
five.field.Total = five.field.Quantity * five.field.Price

Checking a text field

This example checks the value in the Status field, if exactly

Approved
, it sets the CanProceed field to
true
.

JavaScript
Check the value in the Status field
if (five.field.Status === 'Approved') {
five.field.CanProceed = true;
}

Working with dates

This example compares the values in the StartDate and EndDate fields, if the end date value is earlier than the start date value an error is triggered.

JavaScript
Compares dates and triggers an error if invalid
let start = five.field.StartDate;
let end = five.field.EndDate;

if (end < start) {
return five.createError('End date cannot be earlier than start date');
}

Using
fieldID
dynamically

You can get the values form

five.field
by using a variable, string, or property name.

JavaScript
Using fieldID dynamically
//variable
let fieldID = 'Comment';
let text = five.field[fieldID];

//string
let text = five.field['Comment'];

//property name
let text = five.field.Comment;

Calculating the average BMI

This example calculates the average BMI using the values stored in the Mass and Height fields and writes the result into the Average field.

Calculate average BMI
function averageBmi(five: Five, context: any, result: FiveError) : FiveError  {
five.field.Average = five.field.Mass / five.field.Height ** 2;
return five.success(result);
}

Calculating the total

This example calculates the total using the values in the Quantity, Price, and Fees fields. If the current form equals Buys the fees are added, otherwise the fees will be deducted.

Calculate total
function CalculateTotal(five: Five, context: any, result: FiveError) : FiveError  {
if (five.actionID() === 'Buys') {
five.field.Total = five.field.Quantity * five.field.Price + five.field.Fees;
} else {
five.field.Total = five.field.Quantity * five.field.Price - five.field.Fees;
}
return five.success();
}

Calculating the total and checking for GST

This example calculates the total using the values in the PricePerItem, Quantity, and GST fields, the GST field is not used if there is no value in the field.

Calculate total and check for GST
function TotalItemsPrice(five: Five, context: any, result: FiveError) : FiveError {
if (five.field.GST !== '' && five.field.GST !== 0.0) {
five.field.Total = five.field.PricePerItem * five.field.Quantity * five.field.GST;
} else {
five.field.Total = five.field.PricePerItem * five.field.Quantity;
}
return five.success();
}