Skip to main content

form

Last updated 8/05/2023

five.form property in functions.

Example One

The function first parses the Quantity field of the five object as a number and assigns it to a variable called qty. Then, it checks if qty is greater than the Quantity field of the Sells form in the stack within the five object. If it is, the function returns an error message using the createError method on the five object and the result parameter. Next, the function checks if qty is greater than the Holding value of the BuyKey field within the Allocations metadata on the five object. If it is, the function returns another error message using the createError method. If neither of these conditions are met, the function returns success.


Check the value in the Quantity field on the Sells form in the stack
function CheckBuyQuantity(five: Five, context: any, result: FiveError) : FiveError {
const qty: number = parseInt(five.field.Quantity);
if (qty > five.form.Sells.Quantity) {
return five.createError(result, 'Stock quantity exceeds quantity in this sale');
}

if (qty > five.getMetadata('Allocations', 'BuyKey', 'Holding')) {
return five.createError(result, 'Stock quantity exceeds remaining stock in this buy');
}

return five.success();
}