31.9 CREATE_TASK Function
This function creates a new task. A new Task (Instance) is created. Depending on the task definition participant setting, the Task is set to state Unassigned
or Assigned
.
If the task definition has a single potential owner, the Task is set to Assigned
.
If the task has multiple potential owners, the Task is set to Unassigned
and can be claimed by any of the potential owners. This procedure throws an exception if no potential owners are found in the corresponding task definition.
Syntax
APEX_HUMAN_TASK.CREATE_TASK (
p_application_id IN NUMBER DEFAULT apex_application.g_flow_id,
p_task_def_static_id IN VARCHAR2,
p_subject IN VARCHAR2 DEFAULT NULL,
p_parameters IN t_task_parameters DEFAULT c_empty_task_parameters,
p_priority IN INTEGER DEFAULT NULL,
p_initiator IN VARCHAR2 DEFAULT NULL,
p_initiator_can_complete IN BOOLEAN DEFAULT NULL,
p_detail_pk IN VARCHAR2 DEFAULT NULL,
p_due_date IN TIMESTAMP WITH TIME ZONE DEFAULT NULL )
RETURN NUMBER;
Parameters
Parameter | Description |
---|---|
p_application_id |
The application ID that creates the Task. |
p_task_def_static_id |
The Task Definition static ID. |
p_subject |
The subject (expression of the Task). |
p_parameters |
The task parameters. |
p_priority |
(Optional) A task priority, default is NULL. If no priority is provided, uses the priority set in the corresponding task definition. |
p_initiator |
(Optional) If TRUE , the initiator of the task instance can approve or reject this task. If no value is provided, the setting in the corresponding task definition is used.
|
p_initiator_can_complete |
(Optional) Enables the initiator of a task to complete the task (default NULL). If this parameter is not specified, the value of the corresponding task definition is used. |
p_detail_pk |
(Optional) A primary key value for the task details. |
p_due_date |
(Optional) Page Item representing the Due Date of the Task. When specified, this value overrides the Due Date provided in the Task Definition this Task is based on. |
Returns
Returns the ID of the newly created task.
Example
The following example creates a requisition item in the system of record in the database and then creates a new Human Task to get the requisition item approved by a user.
DECLARE
l_req_id number;
l_req_item varchar2(100) := 'Some requisition item requiring approval';
l_req_amount number := 2499.42;
l_task_id number;
BEGIN
insert into requisitions(created_by, creator_emailid, item, item_amount, item_category)
values (:emp_uid, :emp_email, l_req_item, l_req_amount, 'Equipment')
returning id into l_req_id;
commit;
l_task_id := apex_approval.create_task(
p_application_id => 110,
p_task_def_static_id => 'REQAPPROVALS',
p_subject => 'Requisition ' || l_req_id || ': ' || l_req_item || ' for ' || l_req_amount,
p_initiator => :emp_uid,
p_initiator_can_complete => true,
p_parameters => apex_approval.t_task_parameters(
1 => apex_approval.t_task_parameter(static_id => 'REQ_DATE', string_value => sysdate),
3 => apex_approval.t_task_parameter(static_id => 'REQ_AMOUNT', string_value => l_req_amount),
4 => apex_approval.t_task_parameter(static_id => 'REQ_ITEM', string_value => l_req_item),
5 => apex_approval.t_task_parameter(static_id => 'REQ_ID', string_value => l_req_id)
),
p_detail_pk => l_req_id
);
END;
Parent topic: APEX_HUMAN_TASK