Skip to main content

actionID()

Last updated 4/03/2026

Definition​

is a function on the
Five
object that returns the action ID for the current action.

Examples​

Logging the executing action to the Five Inspector​

This code demonstrates how to log the currently executing action.

JavaScript
Log the current action
five.log("Current action:" + five.action());

Conditional logic for multiple actions​

This code demonstrates how to use

five.actionID()
to determine which action is currently executing in the application and conditionally run logic based on that action.

JavaScript
Run action-specific code
const action = five.actionID();

if (action === "SalesReport") {
generateSalesSummary();
}

if (action === "CustomerForm") {
initializeCustomerDefaults();
}

Restricting logic to a specific action​

This code demonstrates how to restrict a script so that it only runs for a specific action, ensuring that the logic executes only when the current action matches the intended action ID.

JavaScript
Restrict execution to a specific action
if (five.actionID() !== "AdminReport") {
five.message("This function can only run from the Admin Report");
}

Calculating the total based on an action​

This function calculates the

Total
field differently depending on the current action. If the action is
Buys
, it adds
Fees
, otherwise, it subtracts
Fees
.

Calculate the total based on the action ID
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();
}

Showing a message on creation​

The function displays a message prompting the user to enter details when creating a new record. Depending on the current action ID, it shows the appropriate message in the UI.

Check the action ID to show correct message
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);
}