Built In Workflow for APEX Applications
Starting in APEX 22.1, Oracle introduced the Approval component, which provides a declarative way to build approval workflows directly within your APEX application. Before this feature, developers had to build custom approval tables, status tracking, email notifications, and delegation logic from scratch. The APEX_APPROVAL API and the associated Approvals component handle all of this with minimal custom code.
Setting Up an Approval Task Definition
In Shared Components, navigate to Task Definitions under Workflows. Create a new task definition specifying the approval type (simple, parallel, or serial), the potential owners (who can approve), and the actions available (approve, reject, delegate, request information). Each task definition can have parameters that carry context from the originating page to the approval task.
Here is how to create an approval task programmatically:
DECLARE
l_task_id NUMBER;
BEGIN
l_task_id := APEX_APPROVAL.CREATE_TASK(
p_task_def_static_id => 'PURCHASE_APPROVAL',
p_subject => 'Purchase Order #' || :P50_PO_NUMBER ||
' - $' || TO_CHAR(:P50_TOTAL, 'FM999,999.00'),
p_initiator => :APP_USER,
p_parameters => APEX_APPROVAL.T_TASK_PARAMETERS(
APEX_APPROVAL.T_TASK_PARAMETER(
static_id => 'PO_ID',
string_value => :P50_PO_ID
)
)
);
-- Store the task ID for reference
UPDATE purchase_orders
SET approval_task_id = l_task_id
WHERE po_id = :P50_PO_ID;
END;
/
The Unified Task List
APEX provides a built in Unified Task List page component that shows all pending tasks for the logged in user. You can add this to your application with a few clicks, giving approvers a single place to see everything waiting for their action. The task list supports filtering, searching, and bulk actions.
Responding to Approval Outcomes
When an approver takes action, you can handle the outcome using a Task Outcome process or by querying the task status in PL/SQL:
-- Check task status
SELECT APEX_APPROVAL.GET_TASK_STATUS(p_task_id => l_task_id)
INTO l_status
FROM DUAL;
-- React to the outcome
IF l_status = 'APPROVED' THEN
process_approved_po(l_po_id);
ELSIF l_status = 'REJECTED' THEN
notify_requester_of_rejection(l_po_id);
END IF;
When to Use APEX_APPROVAL vs Custom Tables
Use the built in approval component when your workflow follows standard approval patterns and you want audit trails, delegation, and deadline handling out of the box. Build a custom solution only when your approval logic is highly nonstandard, such as dynamic routing based on complex business rules that change frequently, or when you need to integrate with an external BPM system.