variable
Last updated 3/02/2026
Accessing a variable
The following code inserts the value of the
ISBN
variable from the Five
object as a parameter to the query.
{{five.variable.ISBN}}

Figure 1 - variable property
Set a variable in one function, and use it elsewhere
The following code stores the ID of a selected customer in the system so it can be used later.
Store customer ID
function SetCustomerID(five: Five, context: any, result: FiveError) : FiveError {
five.setVariable("selectedCustomerID", customerID);
return five.success(result);
}
Store customer ID
function SetCustomerID(five, context, result) {
five.setVariable("selectedCustomerID", customerID);
return five.success(result);
}
Backend function - use the same variable
Before calling the
CustomerOrders()
function, the selected ID is set using setVariable()
in the SetCustomerID()
function.
The following code uses the ID of a selected customer to process customers orders.
Process customer orders
function CustomerOrders(five: Five, context: any, result: FiveError) : FiveError {
const customerID = five.getVariable("selectedCustomerID");
if (!customerID) {
return five.createError("No customer selected");
}
five.log("Loading orders for customer: ", customerID);
return five.success(result);
}
Process customer orders
function CustomerOrders(five, context, result) {
const customerID = five.getVariable("selectedCustomerID");
if (!customerID) {
return five.createError("No customer selected");
}
five.log("Loading orders for customer: ", customerID);
return five.success(result);
}