25.1.9.1.11.3.1 Determining Assignees Generically

Use a package function to determine potential owners for a task at runtime.

The Purchase Office Supplies task definition in this example configures a static username DAVID as the business administrator, and uses an Expression to call an OWNERS_FOR_TASK function in the package YOUR_APP_PKG. This dynamically determines the list of potential owners. It returns a comma-separated list of case-sensitive usernames. The function accepts the task ID and primary key of the business entity related to the task instance as parameters. The Purchase Office Supplies task definition does not use an associated business entity row, nor does it accept a Details Primary Key at creation time. However, this function signature illustrates a best practice for providing key information that generic task owner assignment logic typically needs.

The figure shows the Purchase Office Supplies task definition in the Task Definition edit page in App Builder and highlights the PL/SQL expression in use for its Potential Owner participants:
your_app_pkg.owners_for_task(:APEX$TASK_ID,:APEX$DETAILS_PK)

Figure 25-54 Participants for Purchase Office Supplies Task Definition



The your_app_pkg specification looks like this:
package your_app_pkg as
    -------------------------------------------------
    -- Returns comma-separated list of case-sensitive
    -- usernames who are potential owners for task id
    -- passed in
    -------------------------------------------------
    function owners_for_task(
        p_task_id   in number,
        p_detail_pk in varchar2)
        return         varchar2;
    -------------------------------------------------
    -- Returns comma-separated list of email 
    -- addresses of potential owners for task id
    -- passed in
    -------------------------------------------------        
    function owner_emails_for_task(
        p_task_id   in number,
        p_detail_pk in varchar2)
        return         varchar2;        
end your_app_pkg;