Skip to main content

success()

Last updated 29/03/2023

Example

The function first checks if the value returned from the method actionID on the Five object is equal to the string "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 fields. If the actionID is not equal to the string "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 the result of calling the success method on the Five object.

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