Skip to main content

actionID()

Last updated 1/07/2024

Example One

The following code calculates the total using the values in the Quantity, Price, and Fees fields. If the action ID returns Buys the fees are added, otherwise the fees will be deducted.

Check if the action ID equals Buys
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 following code shows a message when creating a record, if the action ID equals Categories one message is shown, if the action ID equals Inventories another message is shown.

Check if the action ID equals Categories or Inventories
function NewCategoryInventory(five: Five, context: any, result: FiveError) : FiveError {
if (five.actionID() === 'Categories' && five.isCreate()) {
five.showMessage('Enter in the details for a new category.')
} else if (five.actionID() === 'Inventories' && five.isCreate()) {
five.showMessage('Enter in the details for a new inventory.')
}
return five.success(result);
}