Skip to main content

field

Last updated 21/05/2024

field
property on the
Five
object in functions.

Example One

The function calculates the average BMI using the values in the Mass and Height fields and enters the result into the Average field when the function is attached to the On Enter event.

Calculate Total Using the Field IDs on the Current Form
function averageBmi(five: Five, context: any, result: FiveError) : FiveError  {
five.field.Average = five.field.Mass / five.field.Height ** 2;
return five.success(result);
}

Example Two

The function 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 Using the Field IDs on the Current Form
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();
}

Example Three

The function calculates the total by multiplying the values in the PricePerItem, Quantity, and GST fields on the current form, the GST field is not used if there is no value in the field.

Calculate Total Using the Field IDs on the Current Form
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();
}