How to Start a Workflow Process from PL/SQL block
February 8th, 2006How to Start a Workflow Process from PL/SQL block
You can call the Workflow Engine APIs to initiate a workflow process through the CreateProcess and StartProcess APIs if you want to perform additional tasks, such as setting item attributes, after creating and before starting the process. If you do not need to perform any additional tasks, you can use the LaunchProcess API, which is a wrapper combining the CreateProcess and StartProcess APIs.
The procedure that executes the Workflow Engine APIs to initiate a process must identify the item type and item key of the process for these APIs. The item type and item key passed to these APIs uniquely identify an item and must be passed to subsequent API calls for each specific process. The process must begin with the standard Start activity or with another function, notification, or process activity, marked as a Start activity node.
Oracle Workflow also includes a Launch Processes Web page for manually initiating workflow processes. The Launch Processes link is available from the Workflow home page in standalone Oracle Workflow or from a workflow administrator responsibility in embedded Oracle Workflow. It is intended for use by the workflow administrator to test workflow processes in a development environment.
For more information, refer to the Workflow Engine APIs chapter in the Oracle Workflow API Reference
Example:
The following example shows how to initiate a process using the CreateProcess,
SetItemUserKey, SetItemAttribute, SetItemOwner, and StartProcess APIs.
function test_wf_calling ()<br /> l_itemtype varchar2(15);<br /> l_itemkey varchar2(15); -- some unique key<br />begin<br /> <br /> l_itemtype := 'NEW_TASK'; <br /> <br /> -- code to have some unique key for this process instance<br /> l_itemkey := 'something'; <br /> <br /> -- which process of the workflow you want to start?<br /> wf_engine.CreateProcess ( ItemType => l_itemtype, <br /> ItemKey => l_itemkey,<br /> Process => 'MAIN_PROCESS');<br /> <br /> -- set user key<br /> wf_engine.SetItemUserKey ( ItemType => l_itemtype,<br /> ItemKey => l_itemkey,<br /> UserKey => ItemUserKey);<br /> -- set owner<br /> wf_engine.SetItemOwner ( itemtype => l_itemtype,<br /> itemkey => l_itemkey,<br /> owner => 'HARDIK' );<br /> <br /> -- Initialize item attributes <br /> -- Text Attribute<br /> wf_engine.setItemAttrText(itemtype => l_itemtype,<br /> itemkey => l_itemkey,<br /> aname => 'RESOURCE',<br /> avalue => 'HARDIK');<br /><br /> -- Date Attribute <br /> wf_engine.setItemAttrDate(itemtype => l_itemtype,<br /> itemkey => l_itemkey,<br /> aname => 'START_DATE',<br /> avalue => '23-Sep-1981');<br /> <br /> -- Now start the process <br /> wf_engine.startprocess(itemtype => l_itemtype,<br /> itemkey => l_itemkey);<br /> <br />end;
Stay tuned for more detailed example…

Posted by Hardik

