Purchase Order Approval Level Query Examples
This page provides a worked example of a multi-level approval query that requires a manager to approve purchase orders.
Example: Manager approval (Level 2)
The following query requires the manager of the requesting custodian to approve the PO. This is a common pattern for "line manager sign-off" workflows.

The query is named Purchase Order Approver Level 2, which places it immediately after Standard Purchase Approval (Level 1) in the approval chain.
Query filter conditions
The query uses two SQL conditions combined with an OR scheme:
Condition 1 — returns the manager of the custodian the PO is for:
SELECT ManagerCustodianID FROM Custodian AS c
INNER JOIN PurchaseOrder AS po ON c.CustodianID = po.ForCustodianID
WHERE po.PurchaseOrderID = %PurchaseOrderID%
Condition 2 — returns the manager of the custodian who requested the PO:
SELECT ManagerCustodianID FROM Custodian AS c
INNER JOIN PurchaseOrder AS po ON c.CustodianID = po.RequestedByCustodianID
WHERE po.PurchaseOrderID = %PurchaseOrderID%
How it works
Either condition can return an approver. If the custodian the PO is for has a manager, or the custodian who requested the PO has a manager, that manager becomes an approver at Level 2. If neither custodian has a manager set in their custodian record, no approval is required at this level and the system moves to the next applicable level.
Related Articles
- Multi-Level Approval — Overview of multi-level approval
- Purchase Order Approval Levels — Configuring approval levels
- Queries and Reports Overview — Introduction to queries and reports