field
Last updated 24/04/2024
field
property on the Five
object in functions.
Example One
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();
}
Calculate Total Using the Field IDs on the Current Form
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();
}
Example Two
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();
}
Calculate Total Using the Field IDs on the Current Form
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();
}