Oracle Workflow Engine APIs

Inside a stored procedure, you must use Workflow Engine APIs to communicate with the Workflow Engine. All Workflow Engine APIs are stored in a PL/SQL package called WF_ENGINE. The following is the list of Workflow Engine APIs present inside the WF_ENGINE package.

Procedure Name
Description
Variable(I=Input, O=Output)
AddItemAttr
Add a new unvalidated runtime item attribute.
Item type(I)
SetItemAttrText
Set the value of a text item attribute.
Item type(I)

Item key(I)

Attribute name(I)

New value(I)
SetItemAttrNumber
Set the value of a number item attribute.
Item type(I)

Item key(I)

Attribute name(I)

New value(I)
SetItemAttrDate
Set the value of a date item attribute.
Item type(I)

Item key(I)

Attribute name(I)

New value(I)
GetItemAttrInfo
Get type information about an item attribute.
Item type(I)

Attribute name(I)

Attribute type(O)

Subtype(O)

Format(O)
GetActivityAttrInfo
Get type information about an activity attribute.
Item type(I)

Item key(I)

Activity ID(I)

Attribute name(I)


Attribute type(O)

Sub-type(O)

Format(O)
SetItemParent
Set the parent/master process for a detail process.
Item type(I)

Item key(I)

Parent item type(I)

Parent item key(I)

Parent context(I)
SetItemOwner
Set the owner of an item.
Item type(I)

Item key(I)

Owner(I)
Set the user-friendly identifier for an item.
Item type(I)

Item key(I)

User key(I)
CB
Callback function used by the Notification System to get and set process attributes, and mark a process complete.
Action(I)

Context(I)

Attribute name(I)

Attribute type(I)

Text attribute value(I,O)

Number attribute value(I,O)

Date attribute value(I,O)
ProcessDeferred
Process all deferred activities within the threshold limits.
Item type(I)

Minimum threshold(I)

Maximum threshold(I)
ProcessTimeOut
Pick up one timed-out activity and execute time-out transition.
Item type(I)
ProcessStuckProcess
Pick up one stuck activity, mark error status, and execute error process.
Item type(I)
Background
Process all current deferred and/or time-out activities within the threshold limits.
Item type(I)

Minimum threshold(I)

Maximum threshold(I)

Process deferred flag(I)

Process timeout flag(I)
BackgroundConcurrent
Send background process for deferred and/or time-out activities to the concurrent manager.
Error buffer(O)

Return code(O)

Item type(I)

Minimum threshold(I)

Maximum threshold(I)

Process deferred flag

Process timeout flag
CreateProcess
Create a new runtime process for an item.
Item type(I)

Item key(I)

Root process(I)
Begins execution of the process.
Item type(I)

Item key(I)
SuspendProcess
Suspends process execution. Outstanding notifications will be allowed to finish, but activity transitions will not occur.
Item type(I)

Item key(I)

Process to suspend(I)
AbortProcess
Abort process execution. Outstanding notifications are cancelled. The process is then considered complete, with a status specified by the result variable.
Item type(I)

Item key(I)

Process to abort(I)

Result(O)
ResumeProcess
Returns a process to normal execution status. Used after a process is suspended.
Item type(I)

Item key(I)

Process to resume(I)
BeginActivity
Determines if the specified activity may currently be performed on the item.
Item type(I)

Item key(I)

Activity(I)
CompleteActivity
Notifies the Workflow Engine that an activity for an item has been completed.
Item type(I)

Item key(I)

Activity(I)

Result(I)
AssignActivity
Assigns the user or role (performer) who will perform an activity.
Item type(I)

Item key(I)

Activity(I)

Performer(I)
HandleError
Resets the process thread to the entered activity and begins execution again from that point.
Item type(I)

Item key(I)

Activity(I)

Command(I)

Result(I)

The last section of the stored procedure body is the EXCEPTION block for exception handling. Any kind of exception handling is allowed in PL/SQL. The only thing you must do is set the context information. 

This is done by the API calls

WF_CORE.CONTEXT(‘your_package_name’, ‘your_procedure_name’, itemtype, itemkey, to_char(actid), funcmode)

Your stored procedure can be in a PL/SQL package. The package groups store procedures within the same category.

Review Questions
1.      Which Work Engine API should you use to begin execution of an activity?
2.      Which Work Engine API should you use to get information about an item’s attributes?
3.      For which functions can you use the Work Engine API Background?
4.      How do you notify the Work Engine about a completed activity?