field
Last updated 10/12/2025
Examples of using
Reading a field value
This example returns the value stored in the Quantity field on the current form.
let qty = five.field.Quantity;
Writing a value to a field
This example sets the Total field on the current form to 100.
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.
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.
five.field.Total = five.field.Quantity * five.field.Price
Checking a text field
This example checks the value in the Status field, if exactly
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.
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
//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.
function averageBmi(five: Five, context: any, result: FiveError) : FiveError {
five.field.Average = five.field.Mass / five.field.Height ** 2;
return five.success(result);
}
function averageBmi(five, context, result) {
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.
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();
}
function CalculateTotal(five, context, result) {
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.
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();
}
function TotalItemsPrice(five, context, result) {
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();
}