Thursday, 6 December 2018

Workflow Engine API’s

WF_ENGINE  is a workflow package which provides APIs that can be called by an application program or a workflow function in the runtime phase to communicate with the Workflow Engine and to change the status of workflow process activities.


To start or run a workflow process
-->WF_ENGINE.CreateProcess creates a new runtime process for a work item.
-->WF_ENGINE.StartProcess begins execution of the specified process.
-->WF_ENGINE.LaunchProcess launches a specified process by creating the new runtime process and beginning its execution.
-->WF_ENGINE.SetItemOwner sets the owner of an existing item.
-->WF_ENGINE.SetItemUserKey sets a user-friendly identifier for an item.
-->WF_ENGINE.GetItemUserKey returns the user-friendly identifier assigned to an item.
-->WF_ENGINE.SetItemParent defines the parent/child relationship for master/detail processes.
-->WF_ENGINE.Event receives an event from the Business Event System into a workflow process.
-->WF_ENGINE.Background runs a background engine to process deferred and timed out activities and stuck processes.
-->WF_ENGINE.CreateForkProcess forks a runtime process by creating a new process that is a copy of the original.
-->WF_ENGINE.StartForkProcess begins execution of the specified new forked process.



To communicate attribute information to the Workflow Engine
-->WF_ENGINE.SetItemAttrText, WF_ENGINE.SetItemAttrNumber, WF_ENGINE.SetItemAttrDate, and WF_ENGINE.SetItemAttrEvent set the value of an item type attribute in a process.
-->WF_ENGINE.SetItemAttrTextArray, WF_ENGINE.SetItemAttrNumberArray, and WF_ENGINE.SetItemAttrDateArray set the values of an array of item type attributes in a process.
-->WF_ENGINE.GetItemAttrText, WF_ENGINE.GetItemAttrNumber, WF_ENGINE.GetItemAttrDate, and WF_ENGINE.GetItemAttrEvent return the value of an item type attribute in a process.
-->WF_ENGINE.GetItemAttrInfo returns information about an item attribute, such as its type and format.
-->WF_ENGINE.AddItemAttr adds a new item attribute to the runtime process.
-->WF_ENGINE.AddItemAttrTextArray, WF_ENGINE.AddItemAttrNumberArray, and WF_ENGINE.AddItemAttrDateArray add an array of new item type attributes to the runtime process.
-->WF_ENGINE.GetActivityAttrText, WF_ENGINE.GetActivityAttrNumber, WF_ENGINE.GetActivityAttrDate, and WF_ENGINE.GetActivityAttrEvent return the value of an activity attribute in a process.
-->WF_ENGINE.GetActivityAttrInfo returns information about an activity attribute, such as its type and format.




To communicate state changes to the Workflow Engine
-->WF_ENGINE.CompleteActivity notifies the engine that the specified activity has been completed for the item, identifying the activity by the activity node label name.
-->WF_ENGINE.CompleteActivityInternalName notifies the engine that the specified activity has been completed for the item, identifying the activity by its internal name.
-->WF_ENGINE.BeginActivity determines if the specified activity can currently be performed and raises an exception if it cannot.
-->WF_ENGINE.AssignActivity assigns an activity to another performer.
-->WF_ENGINE.GetActivityLabel returns the instance label of an activity, given the internal activity instance identification.
-->WF_ENGINE.AbortProcess aborts process execution and cancels outstanding notifications.
-->WF_ENGINE.SuspendProcess suspends process execution so that users cannot transition items to new activities.
-->WF_ENGINE.ResumeProcess returns a suspended process to normal execution status.
-->WF_ENGINE.HandleError handles any activity that has encountered an error. This API can also be called for any arbitrary activity in a process to roll back part of the process to that activity.
-->WF_ENGINE.ItemStatus returns the status and results for the root process of the specified item instance.

/* Formatted on 7/13/2015 6:01:27 PM (QP5 v5.163.1008.3004) */
--<<Sample Code>>


DECLARE
   l_itemtype   VARCHAR2 (30) := 'XX_TEST';
   l_itemkey    VARCHAR2 (300) := 'TEST';
BEGIN
   BEGIN
      wf_engine.createprocess (l_itemtype, l_itemkey, 'XX_MAIN_TEST');
   EXCEPTION
      WHEN OTHERS
      THEN
         DBMS_OUTPUT.put_line ('Error in create process:' || SQLERRM);
   END;

   BEGIN
      wf_engine.setitemuserkey (itemtype   => l_itemtype,
                                itemkey    => l_itemkey,
                                userkey    => 'USERKEY: ' || l_itemkey);
   EXCEPTION
      WHEN OTHERS
      THEN
         DBMS_OUTPUT.put_line ('Error in set userkey process:' || SQLERRM);
   END;


   BEGIN
      wf_engine.setitemowner (itemtype   => l_itemtype,
                              itemkey    => l_itemkey,
                              owner      => 'SYSADMIN');
   EXCEPTION
      WHEN OTHERS
      THEN
         DBMS_OUTPUT.put_line ('Error in set owner process:' || SQLERRM);
   END;

   BEGIN
      wf_engine.startprocess (l_itemtype, l_itemkey);
      DBMS_OUTPUT.put_line ('Done');
      DBMS_OUTPUT.put_line ('Process started');
      COMMIT;
   EXCEPTION
      WHEN OTHERS
      THEN
         DBMS_OUTPUT.put_line ('Error in set owner process:' || SQLERRM);
   END;
END;



/