25.1.9.2.2 Generating Page URL for Notification

Generate an absolute page URL for email or push notification links.

After enabling deep linking, use a function like the one below to generate a link to the page for the user to provide additional details. The GET_URL function in the APEX_PAGE package returns a relative URL by default. This means the https://example.com part of the URL is omitted. The browser interprets such a link relative to the page in which you embed it. Relative URLs are fine in an application page, but when generating a page link for an email or push notification, use an absolute URL instead. The user can click on this complete URL from any context.

Notice the ABSOLUTE_PAGE_URL function uses v('APEX$WORKFLOW_ID'). In a workflow activity context, this variable returns the workflow instance ID. The function assumes the target page number n has two hidden page items Pn_WORKFLOW_ID and Pn_ACTIVITY_STATIC_ID. Finally, note that it passes true to p_absolute_url and 0 to p_session.

function absolute_page_url(
    p_page                         in number,
    p_activity_static_id           in varchar2)
    return                            varchar2
is
    c_workflow_page_item constant varchar2(255)
        := 'P'||p_page||'_WORKFLOW_ID';
    c_activity_static_id_item constant varchar2(255)
        := 'P'||p_page||'_ACTIVITY_STATIC_ID';
begin
    return apex_page.get_url(
            p_page         => p_page,
            p_items        => c_workflow_page_item
                              ||','
                              ||c_activity_static_id_item,
            p_values       => v('APEX$WORKFLOW_ID')
                              ||','
                              ||p_activity_static_id,
            p_absolute_url => true,
            p_session      => 0,
            p_debug        => 'NO');
end absolute_page_url;