Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Workflow task is not marked as COMPLETED (still in WAITING state), even though the task is executed in Oracle APEX

Panche KaradzovOct 31 2023 — edited Oct 31 2023

I have a question! I've designed a workflow for a test app I made to practice tasks and workflows. It is a hotel reservation app in which the guest makes a reservation, and then a user with role reception has to activate the reservation. The workflow starts after the reservation is created (as supposed to). However, when the receptionist clicks to activate the reservation, the task gets completed (it is removed from the tasks console) and the CHECK IN task is created (the next in the sequence of tasks) in the tasks console. However, when i open the workflow instance, i see that the task to activate the reservation is still there in a waiting state and not completed. If i manually accept or reject the task through the tasks console, the task gets marked as completed in the workflow instance.

This is the code for creating the ACTIVATE RESERVATION task instance:

DECLARE
    V_ID NUMBER;
    V_TASK NUMBER;
BEGIN
    SELECT MAX(RESERVATION_ID) INTO V_ID FROM HR_RESERVATION;
    V_TASK := APEX_APPROVAL.CREATE_TASK(
        P_APPLICATION_ID => 297905,
        P_TASK_DEF_STATIC_ID => 'ACTIVATE_RESERVATION',
        P_SUBJECT => 'Activate Reservation - ' || V_ID,
        P_INITIATOR => :APP_USER,
        P_PARAMETERS => APEX_APPROVAL.T_TASK_PARAMETERS(
            1 => APEX_APPROVAL.T_TASK_PARAMETER(STATIC_ID => 'RESERVATION_ID', STRING_VALUE => :P10_RESERVATION_ID)
        ),
        P_DETAIL_PK => V_ID
    );
    UPDATE HR_RESERVATION SET TASK_ID = V_TASK WHERE RESERVATION_ID = V_ID;
END;

This is the code for activating the reservation and creating a check in task (executed right after activating reservation):

DECLARE
    V_TASK_ID NUMBER;
    V_NEW_TASK_ID NUMBER;
    V_ROOM NUMBER;
BEGIN
    SELECT MIN(ID) INTO V_ROOM FROM HR_ROOM WHERE ROOM_TYPE_ID = :P10_ROOM_TYPE_ID AND ROOM_STATUS_ID = 1;
    SELECT TASK_ID INTO V_TASK_ID FROM HR_RESERVATION WHERE RESERVATION_ID = :P10_RESERVATION_ID;
    APEX_APPROVAL.APPROVE_TASK(
        P_TASK_ID => V_TASK_ID,
        P_AUTOCLAIM => TRUE
    );
    V_NEW_TASK_ID := APEX_APPROVAL.CREATE_TASK(
        P_APPLICATION_ID => 297905,
        P_TASK_DEF_STATIC_ID => 'CHECK_IN',
        P_SUBJECT => 'Check in - ' || :P10_RESERVATION_ID || ' for room - ' || V_ROOM,
        P_INITIATOR => :APP_USER,
        P_PARAMETERS => APEX_APPROVAL.T_TASK_PARAMETERS(
            1 => APEX_APPROVAL.T_TASK_PARAMETER(STATIC_ID => 'RESERVATION_ID', STRING_VALUE => :P10_RESERVATION_ID),
            2 => APEX_APPROVAL.T_TASK_PARAMETER(STATIC_ID => 'ROOM_ID', STRING_VALUE => V_ROOM)
        ),
        P_DETAIL_PK => :P10_RESERVATION_ID
    );
    UPDATE HR_RESERVATION SET TASK_ID = V_NEW_TASK_ID, ROOM_ID = V_ROOM, IS_ACTIVE = 1
    WHERE RESERVATION_ID = :P10_RESERVATION_ID;
    UPDATE HR_ROOM SET ROOM_STATUS_ID = 2, USER_ID = :P10_USER_ID WHERE ID = V_ROOM;
END;

How do I fix this? Is it a bug or I am the problem? I read on the API page that after executing APPROVE_TASK, the task gets into COMPLETED state...

EDIT 1: I just noticed the task to activate reservation is still there in the tasks console window…

Comments
Post Details
Added on Oct 31 2023
1 comment
617 views