Skip to main content

stack

Last updated 19/12/2025

Examples of using

five.stack
. Each example shows you how to read values on the forms in the stack using the
datasourceID
and the
primaryKey
.

Read the current parent key

This example reads the OrderKey field in the parent form. It is useful for debugging and learning what is in the stack.

Gets the current OrderKey in the stack
function logOrderKey(five: Five, context: any, result: FiveError) : FiveError {
const orderKey = five.stack.Order.OrderKey;
console.log('Current OrderKey:', orderKey);
return five.success();
}

Use in a server-side function

This example reads the PatientKey field in the parent form to check if the current patient has a post code.

Gets the current PatientKey in the stack to check if post code code exists
function PatientPostCodeCheck(five: Five, context: any, result: FiveError) : FiveError {
const pc = five.executeQuery(
`SELECT PostCode FROM Address WHERE PatientKey=?`, 0, five.stack.Patient.PatientKey
);

if (!pc.isOk() || !pc.records.PostCode) {
return five.createError(pc, 'Patient record needs updating');
}

return five.success(result);
}

Use in a SQL query parameter

This example filters the lookup by the RestaurantKey in the stack.

MySQL
Gets the primary key of the restaurant form in the stack
SELECT
AddressKey,
CONCAT(AddressLine1, " ", Suburb) AS Address
FROM
Address
WHERE
RestaurantKey = ?

The parameter would be entered as:

{{five.stack.Restaurant.RestaurantKey}}