Skip to main content

field

Last updated 12/04/2023

five.field property in functions.

Example One

The function first checks if the actionID property on the five object is equal to Buys. If it is, then the function calculates the total cost of the purchase by multiplying the values in the Quantity and Price fields, and adding the value in the Fees field. If the actionID is not equal to Buys, then the function calculates the total cost by subtracting the value in the Fees field instead. After calculating the total cost, the function sets the Total field to the calculated value. Finally, the function returns success.


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 Two

The function first checks if the value in the GST field is not an empty string or 0.0. If it is not empty, the function calculates the total price by multiplying the values in the PricePerItem, Quantity, and GST fields. If it is empty, the function calculates the total price by multiplying the values in the PricePerItem and Quantity fields only. Finally, the function returns success.


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();
}