APEX: Displaying Human Task Request Details

Customising the generated Task Details Page to display request details

APEX announced the Approval Task in 2022 and this feature has continued to evolve support both approval and action tasks. Tasks are a unique component in APEX where a search component like report list of mixed tasks are shown to the user and when selected the task type will open a unique task details page.

This page is generated and by default contains all of the task details, and regardless of the task, this page is exactly the same. It will contain Subject, Overview, Task actions, Details, Comments, and History regions.

What is lacking are the data associated with the task request, the laptop request information, travel or leave request details, where to, starting and ending when, for what reason, etc. i.e. the details a business user would want to see for any assigned task or request.

About this Post

I will share some tips on how I I setup my application’s to ease adding new request related regions to this page and it is just that an APEX page in your application. Nothing is stopping you from customising it an any supported APEX way.

or

or

As with many relation database objects, the primary foreign keys are essential to navigating datasets. Working with APEX Human Tasks are no different.

Tasks have unique identifiers, APEX$TASK_ID and for most a related foreign key is stored with the task record as the detail primary key or APEX$TASK_PK

💡
APEX Task substitution strings are described in the Substitution Strings and Bind Variables for Tasks documentation section.

The TASK_ID uniquely identifies the task instance and the TASK_PK uniquely identifies the record containing the details that are important to the business.

💡
The APEX_TASKS runtime view can be reference to view all of the task instance’s details.

Setting Your Record Detail PK

As mentioned above the APEX_TASKS view contains all of the task instance details and set detail PK. The Detail PK can be set when creating the human task instance.

In this case, my process creates a human task and sets the details primary key item to the Primary Key of a new complaint and page item P11_ID.

Getting Your Record Details

Querying the APEX_TASKS view I can see my newly created task with the Detail PK as well.

select detail_pk, task_id, subject, application_id, task_def_name, task_def_static_id,state 
from apex_tasks
where task_id = 14819211486972323

Displaying the Human Task Request Details

When using the application, we would navigate from the Unified Task List to the Task Details page, setting the current TASK_ID page item.

On the Task Details page, use a page process, in the Pre-Rendering Before Header stage, initialise the records PK page item.

For Report regions added the where clause condition and submit the page item, for Form regions, ensure that the process that sets the PK of the Form region is placed above the “Initalize form <My Form Region>” process and APEX will retrieve the relevant record.

The Complaint region is of type form and with the PK page item set, APEX loads the record for us.

Secondary Implementation Option

In the first option we leverage the runtime views from APEX but this may not cover your use case requirements, your organisation is so large that even with purging there are too many tasks for fast queries or perhaps you just want to look at the record see any associated foreign relationships.

For this adding a task id column along with additional task details you want to base request table and update these columns during the Task’s State change event actions.

Getting the relevant record with a where clause will be simple enough.

Conclusion

Task Detail pages are normal APEX pages and can be easily modified to be fit for purpose.

The Human Tasks runtime view, APEX_TASKS, contains details for task instances no matter the state, created, delegated, approved, rejected or complete, as long as the task has not been purged.

The Sample Workflow, Approvals, and Tasks application, page 15 - Salary Change Details, demonstrates customising, hiding and adding regions to the Task Details page, in contrast to page 2, which is right out of the box.

Checkout the Salary Increment and Salary History regions. Screenshot taken from the docs: Example: Approval Tasks and Action Tasks

Description of approvals_salary_change_details.png follows

The only other tip that I would pass along, if you a bit anal like myself, I like to group my pages, keeping normal reports & Forms together by functional area, pages for Workflows together and the same for Tasks, etc.

While creating a new Task Definition, set the Page Number in the Task Details Page Number field before Clicking the Create Task Details Page and it will use the entered number just like overriding the page number in the Page Wizard.

Hopefully this is useful.