20.14.1.4 Editing a Task Definition

Edit Task Definition details from the Shared Components page, under the Workflows and Automations heading.

20.14.1.4.1 Example: Editing Task Definition Participants

Edit Task Definition Participants by accessing the Task Definition in the Shared Components page.

This example uses the Sample Workflows, Approvals, and Tasks application, which can be installed from the Gallery. In this example, suppose that Bo, one of the potential owners in the Job Change task definition, has become a business administrator for that definition.

To edit Task Definition Participants:

  1. Select the Sample Workflows, Approvals, and Tasks app.
  2. Navigate to the Task Definitions page:
    1. On the Application home page, click Shared Components.
    2. Under Workflows and Automations, select Task Definitions.
  3. Click Job Change.
  4. Under Participants, select the row where Participant Type is Potential Owner and Value is Bo.
  5. Click Edit.
  6. Change the Participant Type from Potential Owner to Business Administrator.
  7. Click Apply Changes.
Bo is now a business administrator on all new Job Change tasks. Job Change tasks that already exist do not change.

20.14.1.4.2 Example: Adding a Vacation Rule Procedure

Add a vacation rule by editing the Task Definition in the Shared Components page.

Note:

This section describes adding a vacation rule procedure to a task definition. You can also add a vacation rule procedure to the application definition. If you add a vacation rule procedure to the application definition, the vacation rule applies to all tasks in the task definition.

Tip:

A vacation rule defined at the task definition level overrides a vacation rule defined at the application level.
This example uses the Sample Workflows, Approvals, and Tasks application, which can be installed from the Gallery. In this example, suppose that Jane, a task participant, is on leave. When Jane is on leave, Scott takes responsibility for Jane's approvals.
Before adding the vacation rule procedure, you must add the following procedure to the APEX workspace:
procedure alternate_job_approvers(
                p_param    in apex_human_task.t_vacation_rule_input,
                p_result  out apex_human_task.t_vacation_rule_result)
    is 
        l_result            apex_human_task.t_vacation_rule_result;
        l_changes           apex_human_task.t_task_participant_changes;
        l_participants      apex_human_task.t_task_participants;
        l_new_participant   apex_human_task.t_task_participant;
        l_old_participant   apex_human_task.t_task_participant;
        l_has_changed       boolean                             := false;
        l_index             pls_integer                         := 1;
    begin
        l_participants := p_param.original_participants;
        for i in 1..l_participants.count loop
            if l_participants(i).value = 'JANE' then
                l_old_participant               :=  l_participants(i);
                l_new_participant.value         := 'SCOTT';
                l_new_participant.type          := 'POTENTIAL_OWNER';
                l_new_participant.identity      := 'USER';
                l_has_changed                   := true;
            end if;
        end loop;
        if l_has_changed then
            l_participants(l_participants.count + 1) := l_new_participant;
        
            l_changes(l_index).old_participant   := l_old_participant;
            l_changes(l_index).new_participant   := l_new_participant;
            l_changes(l_index).change_reason     := 'Jane is out on maternity leave';
        end if;
        l_result.participant_changes            := l_changes;
        l_result.has_participant_changes        := l_has_changed;
        p_result                                := l_result;
    end;
For more information on adding a procedure, see Creating a Procedure in Oracle APEX SQL Workshop Guide.

To add a vacation rule procedure:

  1. Select the Sample Workflows, Approvals, and Tasks app.
  2. Navigate to the Task Definitions page:
    1. On the Application home page, click Shared Components.
    2. Under Workflows and Automations, select Task Definitions.
  3. Click Job Change.
  4. Under Participants, enter the vacation rule procedure name in Vacation Rule Procedure.
    The procedure name should be in the format [schemaName.[packageName]].procedureName.
  5. Click Apply Changes.
Scott is now an alternate participant for Jane.

20.14.1.4.3 Example: Editing Task Definition Parameters

Edit Task Definition Parameters by accessing the Task Definition in the Shared Components page.

This example uses the Sample Workflows, Approvals, and Tasks application, which can be installed from the Gallery. In this example, suppose that for Job Change requests, you want to display the old job title as well as the new job title on 2 - Task Details.

To edit Task Definition Parameters:

  1. Select the Sample Workflows, Approvals, and Tasks app.
  2. Navigate to the Task Definitions page:
    1. On the Application home page, click Shared Components.
    2. Under Workflows and Automations, select Task Definitions.
  3. Click Job Change.
  4. Under Parameters, click Add Row.
    1. Static Id - JOB
    2. Label - Previous Job
    3. Data Type - String
    4. Required - Yes
    5. Visible - Yes
    6. Updatable - Yes
  5. Click Apply Changes.
  6. Go back to the application home page, and open 7 - Request Job Change in Page Designer.
  7. Open the Processing tab, and expand the Submit Task process.
  8. Under Parameters, select Previous Job.
  9. Under Value, set the Type to Item.
  10. Set the item to P7_JOB.
  11. Click Save.
    Now, when 7 - Request Job Change is saved, the Previous Job value will be stored.
  12. Open 2 - Task Details in Page Designer, and confirm that the Details section contains the columns PARAM_LABEL and PARAM_VALUE.
    All visible parameters, including the new Previous Job parameter, are visible in the Details section of the Task Details page. Since the parameter is marked as updatable, the task details section has an Edit button to edit the task parameter when the logged-in user is the actual owner of the task.
To test this change, go to the Employees page, and request a new job change. After submitting the Request Job Change page, access the task details page through My Requests or Approvals Administration. Under the Details section, you can see both the new job and the previous job.

20.14.1.4.4 Example: Adding and Editing Task Definition Actions

Add and edit Task Definition Actions by accessing the task definition in the Shared Components page.

This example uses the Sample Workflows, Approvals, and Tasks application, which can be installed from the Gallery. In this example, suppose that you want to add an action that logs an event every time a task is complete.
This example requires a metrics table to be added to the Sample Workflows, Approvals, and Tasks app through the SQL Commands page of the SQL Workshop.
CREATE TABLE EBA_DEMO_APPR_METRICS( 
  ID NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY,
  TASK_DEF_STATIC_ID VARCHAR2(255),
  OUTCOME_CODE VARCHAR2(32),
  APPROVER VARCHAR2(255),
  APPROVAL_DATE DATE,
  DAYS_ELAPSED NUMBER
);       

To add and edit Task Definition Actions:

  1. Select the Sample Workflows, Approvals, and Tasks app.
  2. Navigate to the Task Definitions page:
    1. On the Application home page, click Shared Components.
    2. Under Workflows and Automations, select Task Definitions.
  3. Click Salary Change.
  4. In the Actions section, click Add Action.
    1. Name - Salary Change Metrics
    2. Type - Execute Code
    3. Execution Sequence - Leave the default value.
    4. On Event - Complete
    5. Outcome - Leave blank.
    6. Success Message - Leave blank.
    7. Location - Local Database
    8. Language - PL/SQL
    9. Code - Enter the sample insert statement.
      insert into eba_demo_appr_metrics(task_def_static_id,outcome_code,approver,days_elapsed,approval_date)
      select task_def_static_id, outcome_code, actual_owner, sysdate - cast(created_on as date), sysdate
      from apex_tasks
      where task_id = :APEX$TASK_ID;
  5. The Error Handling, Server Side Condition, and Advanced sections can be left as-is.
  6. Click Create.
  7. Click Apply Changes.
The new action adds a row into EBA_DEMO_APPR_METRICS every time a Salary Change task is completed. You could set up an interactive report based on this table to allow users to view metrics on approval tasks.