Skip to main content


Last updated 22/12/2022


Example One

five.stack in a function.

The following code checks if a patient's address has a postcode. To find the associated address for the patient we use the Patient Key (Primary key of the Patient table) in the stack.

five.stack in a function
function UserDetailsUpToDate(five, context, result) {
// note: error handling is ignored in this example for abbreviation
const db = five.getDatabaseConnectionByID('AppDB');
const tx = five.startTransaction(db);
const sql = `SELECT PostCode FROM Address WHERE PatientKey=?`;
const results = five.executeQuery(tx, sql, five.stack.Patients.PatientKey);
if (results.values['PostCode'] === '') {
return five.createError(result, 'Patient records need updating');

return five.success(result);

Example Two

five.stack in a query.

The following syntax uses the Type parameter to retrieve all the billing addresses associated with the selected Restaurant record in the stack. The RestaurantKey (Primary Key of the Restaurant table) is used in the stack as a parameter in the query.

The IN condition allows another form with no RestaurantKey in the stack to resolve the values by using the current Orders.RestaurantKey value.

Billing Address
CONCAT(AddressLine1, " ", AddressLine2) AS Address

WHERE Type = ? AND (RestaurantKey = ? OR RestaurantKey IN (Select Orders.RestaurantKey from Orders WHERE OrdersKey = ?))

The following image demonstrates how to enter the five.stack property as a parameter on the Query form. Please refer to the ROS application to see how to enter constant and expression parameters on the Parameters page on the Query form.

Add a Parameter Using the five.stack Property
Figure 1 - Add a parameter using the five.stack property