Skip Headers

Oracle Workflow API Reference
Release 2.6.4

Part Number B15855-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Skip Headers

Oracle Workflow API Reference
Release 2.6.4
Part Number B15855-02
Go to Table of Contents
Contents
Go to previous page
Previous
Go to next page
Next

Workflow Engine APIs

Overview of the Workflow Engine

The Workflow Engine manages all automated aspects of a workflow process for each item. The engine is implemented in server-side PL/SQL and is activated whenever a call to a workflow procedure or function is made. Since the engine is embedded inside the Oracle Database, if the Workflow server goes down for any reason, the Oracle Database is able to manage the recovery and transactional integrity of any workflow transactions that were running at the time of the failure.

Additionally, Workflow engines can be set up as background tasks to perform activities that are too costly to execute in real time.

The Workflow Engine performs the following services for a client application:

The state of a workflow item is defined by the various states of all activities that are part of the process for that item. The engine changes activity states in response to an API call to update the activity. The API calls that update activity states are:

Based on the result of a previous activity, the engine attempts to execute the next activity directly. An activity may have the following status:

Attention: The Workflow Engine traps errors produced by function activities by setting a savepoint before each function activity. If an activity produces an unhandled exception, the engine performs a rollback to the savepoint, and sets the activity to the ERROR status. For this reason, you should never commit within the PL/SQL procedure of a function activity. The Workflow Engine never issues a commit as it is the responsibility of the calling application to commit.

For environments such as database triggers or distributed transactions that do not allow savepoints, the Workflow Engine automatically traps "Savepoint not allowed" errors and defers the execution of the activity to the background engine.

Note: The Oracle Database supports autonomous transactions. By embedding the pragma AUTONOMOUS_TRANSACTION in your procedure, you can perform commits and rollbacks independently of the main transaction. Oracle treats this as a separate session; as such, you will not have access to any database changes that were made in the main session but are not yet committed. Consequently, you are restricted from updating workflow-specific data in an autonomous transaction; for instance, you cannot set item attributes. You cannot access this data because the item itself has not yet been committed, and because you may have lock contentions with the main session.

Oracle Workflow will not support autonomous commits in any procedure it calls directly. If you need to perform commits, then embed your SQL in a subprocedure and declare it as an autonomous block. This subprocedure must be capable of being rerun. Additionally, note that Oracle Workflow handles errors by rolling back the entire procedure and setting its status to ERROR. Database updates performed by autonomous commits cannot be rolled back, so you will need to write your own compensatory logic for error handling. For more information, see: Autonomous Transactions, Oracle Database Concepts.

Oracle Workflow Java Interface

The Oracle Workflow Java interface provides a means for any Java program to integrate with Oracle Workflow. The Oracle Workflow Engine and Notification APIs are accessible through public server PL/SQL packages and published views. The Oracle Workflow Java interface exposes those APIs as Java methods that can be called by any Java program to communicate with Oracle Workflow. The Java methods directly reference the WF_ENGINE and WF_NOTIFICATION PL/SQL package procedures and views and communicate with the Oracle Workflow database through JDBC.

The methods are defined within the WFEngineAPI class and the WFNotificationAPI class, in the Java package 'oracle.apps.fnd.wf.engine'. If a Workflow Engine or notification API has a corresponding Java method, its Java method syntax is displayed immediately after its PL/SQL syntax in the documentation. See: Workflow Engine APIs and Notification APIs.

Additionally, Java functions can be incorporated within Workflow processes as external Java function activities. This functionality is currently only available for the standalone version of Oracle Workflow. The custom Java classes for these activities are implemented as classes that extend the WFFunctionAPI class. The custom classes must follow a standard API format so that they can be properly executed by the Oracle Workflow Java Function Activity Agent. See: Standard API for Java Procedures Called by Function Activities, Oracle Workflow Developer's Guide and Function Activity, Oracle Workflow Developer's Guide.

The WFFunctionAPI class and the WFAttribute class also contain methods that can be called to communicate with Oracle Workflow. These classes are defined in the Java package 'oracle.apps.fnd.wf'. See: Workflow Function APIs and Workflow Attribute APIs.

Java programs that integrate with Oracle Workflow should include the following import statements to provide access to classes required by Oracle Workflow:

import java.io.*; 
import java.sql.*; 
import java.math.BigDecimal; 

import oracle.sql.*; 
import oracle.jdbc.driver.*;

import oracle.apps.fnd.common.*; 
import oracle.apps.fnd.wf.engine.*; 
import oracle.apps.fnd.wf.*; 

Oracle Workflow Context

Each Oracle Workflow Java method that accesses the database requires an input of a WFContext object. The WFContext object consists of database connectivity information which you instantiate and resource context information that the WFContext class instantiates. To call one of these Workflow Java APIs in your Java program, you must first instantiate a database variable of class WFDB with your database username, password and alias. You can also optionally supply a JDBC string. Then you must instantiate the WFContext object with the database variable. You can retrieve the system property CHARSET to specify the character set for the database session. The following code excerpt shows an example of how to instantiate these objects.

WFDB myDB;
WFContext ctx;

myDB = new WFDB(m_user, m_pwd, m_jdbcStr, m_conStr);
m_charSet = System.getProperty("CHARSET");
if (m_charSet == null) { // cannot be null
  m_charSet = "UTF8";

}

try {
  ctx = new WFContext(myDB, m_charSet); 
  // m_charSet is 'UTF8' by default

  if (ctx.getDB().getConnection() == null) {
    // connection failed
    return;
  }

  // We now have a connection to the database.
}

catch (Exception e) {
// exit Message for this exception
}

If you have already established a JDBC connection, you can simply set that connection into the WFContext object, as shown in the following example:

WFContext ctx;

m_charSet = System.getProperty("CHARSET");
if (m_charSet == null) { // cannot be null
  m_charSet = "UTF8";
}

ctx = new WFContext(m_charSet); 
// m_charSet is 'UTF8' by default

ctx.setJDBCConnection(m_conn);  
// m_conn is a pre-established JDBC connection

The Oracle Workflow Java APIs can be used safely in a thread, with certain restrictions:

There is no synchronized code inside the Oracle Workflow Java APIs, but there are no shared resources, either.

There is also no connection pooling in the Oracle Workflow Java APIs. For Oracle Applications, connection pooling is implemented at the AOL/J level; after you get the JDBC connection, you use the WFContext.setJDBCConnection() API to set the connection. This approach lets you manage your JDBC connection outside of the Oracle Workflow APIs.

Sample Java Program

Oracle Workflow provides an example Java program that illustrates how to call most of the Workflow Engine and Notification Java APIs. The Java program is named WFTest. It calls the various Java APIs to launch the WFDEMO process, set and get attributes, and suspend, resume, and abort the process, as well as the APIs to send a notification, set and get notification attributes, and delegate and transfer the notification. Before running the WFTest Java program, make sure you define CLASSPATH and LD_LIBRARY_PATH for the Oracle JDBC implementation and a supported version of Oracle. For example, on UNIX, use the following commands:

setenv CLASSPATH 
<Workflow_JAR_file_directory>/wfapi.jar:${ORACLE_HOME}/jdbc/lib/classes111.zip

setenv LD_LIBRARY_PATH ${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}

Note: If you are using the standalone version of Oracle Workflow, the Workflow JAR files are located in the <ORACLE_HOME>/jlib directory. If you are using the version of Oracle Workflow embedded in Oracle Applications, the Workflow JAR files are located in the <ORACLE_HOME>/wf/java/oracle/apps/fnd/wf/jar/ directory.

To initiate the WFTest program, run Java against oracle.apps.fnd.wf.WFTest. For example, on UNIX, enter the following statement on the command line:

$java oracle.apps.fnd.wf.WFTest

The source file for this program is also included in your Oracle Workflow installation so that you can view the sample code. The source file is named WFTest.java and is located in the <ORACLE_HOME>/wf/java/oracle/apps/fnd/wf/ directory.

Additional Workflow Engine Features

In addition to managing a process, the Workflow Engine also supports the following features:

Completion Processing

Engine processing is triggered whenever a process activity completes and calls the Workflow Engine API. The engine then attempts to execute (or mark for deferred execution) all activities that are dependent on the completed activity.

Note: A process as a whole can complete but still contain activities that were visited but not yet completed. For example, a completed process may contain a standard Wait activity that is not complete because the designated length of time to wait has not yet elapsed. When the process as a whole completes, the Workflow Engine marks these incomplete activities as having a status of COMPLETE and a result of #FORCE. This distinction is important when you review your process status through the Workflow Monitor.

Deferred Processing

The engine has a deferred processing feature that allows long-running tasks to be handled by background engines instead of in real time. Deferring the execution of activity functions to background engines allows the Workflow Engine to move forward to process other activities that are currently active. The engine can be set up to operate anywhere on a continuum between processing all eligible work immediately, to processing nothing and marking all transitions as deferred.

Each activity has a user-defined processing cost. You can set this cost to be small if the activity merely sets an item attribute, or you may set it to be very high if the activity performs a resource-intensive operation. If the result of a completed activity triggers the execution of a costly function, you might want to defer the execution of that costly function to a background engine.

The Workflow Engine integrates with Oracle Advanced Queues to carry out deferred processing. If a function activity has a cost that exceeds the main threshold cost, the Workflow Engine marks that activity with a status of 'DEFERRED' in the workflow status tables and enqueues the deferred activity to a special queue for deferred activities. A special queue processor called the background engine checks and processes the activities in the 'deferred' queue. The order in which the deferred activities are processed are based on the first in, first out ordering of an activity's enqueue time. At least one background engine must be set up to run at all times. Some sites may have multiple background engines operating at different thresholds or item type specifications, to avoid tying up all background processing with long-running operations.

See: Setting Up Background Engines, Oracle Workflow Administrator's Guide, Activity Cost, Oracle Workflow Developer's Guide, and Deferring Activities, Oracle Workflow Administrator's Guide.

Error Processing

Errors that occur during workflow execution cannot be directly returned to the caller, since the caller generally does not know how to respond to the error (in fact, the caller may be a background engine with no human operator). You can use Oracle Workflow Builder to define the processing you want to occur in case of an error. Use Oracle Workflow Builder to assign the Default Error Process associated with the System:Error item type or create your own custom error process. See: Error Handling for Workflow Processes, Oracle Workflow Developer's Guide.

The error process can include branches based on error codes, send notifications, and attempt to deal with the error using automated rules for resetting, retrying, or skipping the failed activity. Once you define an error process, you can associate it with any activity. The error process is then initiated whenever an error occurs for that activity. See: To Define Optional Activity Details, Oracle Workflow Developer's Guide.

The Workflow Engine traps errors produced by function activities by setting a savepoint before each function activity. If an activity produces an unhandled exception, the engine performs a rollback to the savepoint, and sets the activity to the ERROR status.

Note: For this reason, you should never commit within the PL/SQL procedure of a function activity. The Workflow Engine never issues a commit as it is the responsibility of the calling application to commit.

The Workflow Engine then attempts to locate an error process to run by starting with the activity which caused the error, and then checking each parent process activity until an associated error process is located.

Looping

Looping occurs when the completion of an activity causes a transition to another activity that has already been completed. The first activity that gets detected as a revisited activity is also called a loop point or pivot activity. The Workflow Engine can handle a revisited activity in one of three ways:

Every activity has an On Revisit poplist field in its Oracle Workflow Builder Details property page. The On Revisit poplist lets you specify the behavior of the Workflow Engine when it revisits the activity in a workflow process. You can set the field to Ignore, Reset, or Loop.

Setting On Revisit to Ignore is useful for implementing activities that should only run once, even though they can be transitioned to from multiple sources. For example, this mode allows you to implement a "logical OR" type of activity which is transitioned to multiple times, but completes after the first transition only.

Setting On Revisit to Reset for an activity is useful when you want to reexecute activities in a loop, but you want to first reset the status of the activities in the loop. Reset causes the Workflow Engine to do the following:

Cancelling an activity is similar to executing the activity, except that the activity is executed in "CANCEL" mode rather than "RUN" mode. You can include compensatory logic in "CANCEL" mode that reverses any operation performed earlier in "RUN" mode.

If you set On Revisit to Reset for the pivot activity of a loop that includes an FYI notification activity, the Workflow Engine cancels the previous notification before reexecuting the loop and sending a new notification to the current performer of the notification activity.

Setting On Revisit to Loop for an activity is useful when you want to simply reexecute activities in a loop without resetting the status of the activities in the loop. Loop causes the Workflow Engine to reexecute the activity in "RUN" mode without executing any "CANCEL" mode logic for the activity.

If you set On Revisit to Loop for the pivot activity of a loop that includes an FYI notification activity, previous notifications remain open when the Workflow Engine reexecutes the loop and sends a new notification to the current performer of the notification activity.

Version / Effective Date

Certain workflow objects in a process definition are marked with a version number so that more than one version of the object can be in use at any one time. These objects are:

If you edit and save any of the above objects in Oracle Workflow Builder to the database, Oracle Workflow automatically creates a new version of that object or the owning object by incrementing the version number by one. If you save edits to any of the above objects to an existing file, then the original objects are overwritten. If you have a process instance that is still running and you upgrade the underlying workflow definition in your Workflow server, the process instance continues to run using the version of the workflow object definitions with which it was originally initiated.

An effective date controls which version of a definition the engine uses when executing a process. When you edit a process, you can save it with an immediate or future effective date. Any new process instance that is initiated always uses the version that is specified to be effective at that point in time. See: Opening and Saving Item Types, Oracle Workflow Developer's Guide.

Note that Oracle Workflow does not maintain versions for other workflow objects. Any modifications that you save to the following objects overwrites the existing definition of the object:

Item Type Attributes

A set of item type attributes is defined at both design-time and runtime for each item. These attributes provide information to the function and notification activities used in the processes associated with the item type.

When you define item type attributes at runtime, you can add either individual attributes or arrays containing several attributes of the same type, using the appropriate Workflow Engine APIs. Similarly, you can set the values of existing attributes either individually or in arrays containing several attributes of the same type.

Use the array APIs whenever you need to add or set the values of large numbers of item type attributes at once. These APIs improve performance by using the bulk binding feature in the Oracle Database to reduce the number of database operations. See: AddItemAttributeArray and SetItemAttributeArray.

Note: These array APIs handle arrays that are composed of multiple item type attributes grouped together by type. Oracle Workflow does not support individual item type attributes that consist of arrays themselves.

Post-Notification Functions

You can associate a post-notification function with a notification activity. The Workflow Engine executes the post-notification function in response to an update of the notification's state after the notification is delivered. For example, you can specify a post-notification function that executes when the notification recipient forwards or transfers the notification. The post-notification function could perform back-end logic to either validate the legitimacy of the forward or transfer or execute some other supporting logic.

The post-notification function should be a PL/SQL procedure written to the same API standards required for function activities. See: Standard API for PL/SQL Procedures Called by Function Activities, Oracle Workflow Developer's Guide.

When you specify a post-notification function, the Workflow Engine first sets the context information to use with the function through the following global engine variables. In some cases the values of the variables differ depending on the mode in which the post-notification function is called.

You can reference these global engine variables in your PL/SQL function.

Note: For RUN mode and TIMEOUT mode, only the WF_ENGINE.context_nid and WF_ENGINE.context_user variables are set.

Note: The WF_ENGINE.context_text variable from earlier versions of Oracle Workflow is replaced by the WF_ENGINE.context_user and WF_ENGINE.context_new_role variables. The current version of Oracle Workflow still recognizes the WF_ENGINE.context_text variable for backward compatibility, but moving forward, you should only use the new WF_ENGINE.context_user and WF_ENGINE.context_new_role variables where appropriate.

Then when the notification's state changes, a notification callback function executes the post-notification function in the mode that matches the notification's state: RESPOND, FORWARD, TRANSFER, QUESTION, or ANSWER.

When a recipient responds, the Workflow Engine initially runs the post-notification function in VALIDATE mode which allows you to validate the response values before accepting the response. Then the Workflow Engine runs the post-notification function in RESPOND mode to record the response. Finally, when the Notification System completes execution of the post-notification function in RESPOND mode, the Workflow Engine automatically runs the post-notification function again in RUN mode. In this mode, the post-notification function can perform additional processing such as vote tallying.

If a notification activity times out, the Workflow Engine runs the post-notification function for the activity in TIMEOUT mode. For a Voting activity, the TIMEOUT mode logic should identify how to tally the votes received up until the timeout.

When the post-notification function completes, the Workflow Engine erases the global engine variables.

As a final step, if the post-notification function is run in TRANSFER mode and Expand Roles is not checked for the notification activity, the Workflow Engine sets the assigned user for the notification to the new role name specified.

Attention: If the post-notification function returns ERROR:<errcode> as a result or raises an exception, the Workflow Engine aborts the operation. For example, if the post-notification function is executed in FORWARD mode and it raises an exception because the role being forwarded to is invalid, an error is displayed to the user and the Forward operation is not executed. The notification recipient is then prompted again to take some type of action.

See: Notification Model.

Synchronous, Asynchronous, and Forced Synchronous Processes

A workflow process can be either synchronous or asynchronous. A synchronous process is a process that can be executed without interruption from start to finish. The Workflow Engine executes a process synchronously when the process includes activities that can be completed immediately, such as function activities that are not deferred to the background engine. The Workflow Engine does not return control to the calling application that initiated the workflow until it completes the process. With a synchronous process, you can immediately check for process results that were written to item attributes or directly to the database. However, the user must wait for the process to complete.

An asynchronous process is a process that the Workflow Engine cannot complete immediately because it contains activities that interrupt the flow. Examples of activities that force an asynchronous process include deferred activities, notifications with responses, blocking activities, and wait activities. Rather than waiting indefinitely when it encounters one of these activities, the Workflow Engine sets the audit tables appropriately and returns control to the calling application. The workflow process is left in an unfinished state until it is started again. The process can be restarted by the Notification System, such as when a user responds to a notification; by the background engine, such as when a deferred activity is executed; or by the Business Event System, such as when an event message is dequeued from an inbound queue and sent to the workflow process. With an asynchronous process, the user does not have to wait for the process to complete to continue using the application. However, the results of the process are not available until the process is completed at a later time.

In addition to regular synchronous and asynchronous processes, the Workflow Engine also supports a special class of synchronous processes called forced synchronous processes. A forced synchronous process completes in a single SQL session from start to finish and never inserts into or updates any database tables. As a result, the execution speed of a forced synchronous process is significantly faster than a typical synchronous process. The process results are available immediately upon completion. However, no audit trail is recorded.

There may be cases when your application requires a forced synchronous process to generate a specific result quickly when recording an audit trail is not a concern. For example, in Oracle Applications, several products require Account Generator workflows to generate a meaningful flexfield code derived from a series of concatenated segments pulled from various tables. The Account Generator workflows are forced synchronous processes that compute and pass back completed flexfield codes to the calling applications instantaneously.

To create a forced synchronous process, you need to set the item key of your process to #SYNCH or to wf_engine.eng_synch, which returns the #SYNCH constant, when you call the necessary WF_ENGINE APIs. Since a forced synchronous process never writes to the database, using a non-unique item key such as #SYNCH is not an issue. Your process definition, however, must adhere to the following set of restrictions:

Attention: If you encounter an error from a forced synchronous process, you should rerun the process with a unique item key in asynchronous mode and check the error stack using the Workflow Monitor or the script wfstat.sql. If the synchronous process completes successfully, the error you encountered in the forced synchronous process is probably due to a violation of one of the above listed restrictions. See: Wfstat.sql, Oracle Workflow Administrator's Guide.

Note: The item key for a process instance can only contain single-byte characters. It cannot contain a multibyte value.

See: Synchronous, Asynchronous, and Forced Synchronous Workflows, Oracle Workflow Administrator's Guide.

Business Events

Events from the Business Event System are represented within workflow processes as event activities. An event activity can either raise, send, or receive a business event.

A Raise event activity raises an event to the Event Manager, triggering any subscriptions to that event. The Workflow Engine calls the WF_EVENT.Raise API to raise the event. See: Raise.

A Send event activity sends an event directly to a Business Event System agent without raising the event to the Event Manager. The Workflow Engine calls the WF_EVENT.Send API to send the event. See: Send.

A Receive event activity receives an event from the Event Manager into a workflow process, which then continues the thread of execution from that activity. The Workflow Engine can receive an event into an activity in an existing process instance that is waiting for the event, using the correlation ID in the event message to match the event with the process to which it belongs. The Workflow Engine can also receive an event into a Receive event activity that is marked as a Start activity to launch a new workflow process. The WF_ENGINE.Event API is used to receive an event into a workflow process. See: Event.

See also: Managing Business Events, Oracle Workflow Developer's Guide and Event Activities, Oracle Workflow Developer's Guide.

Workflow Engine APIs

The Workflow Engine APIs can be called by an application program or a workflow function in the runtime phase to communicate with the engine and to change the status of each of the activities. These APIs are defined in a PL/SQL package called WF_ENGINE.

Many of these Workflow Engine APIs also have corresponding Java methods that you can call from any Java program to integrate with Oracle Workflow. The following list indicates whether the Workflow Engine APIs are available as PL/SQL functions/procedures, as Java methods, or both.

Attention: Java is case-sensitive and all Java method names begin with a lower case letter to follow Java naming conventions.

Related Topics

Standard API for PL/SQL Procedures Called by Function Activities, Oracle Workflow Developer's Guide

CreateProcess

PL/SQL Syntax

procedure CreateProcess
  (itemtype in varchar2,
   itemkey in varchar2,
   process in varchar2 default '',
   user_key in varchar2 default null,
   owner_role in varchar2 default null);

Java Syntax

public static boolean createProcess
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String process)

Description

Creates a new runtime process for an application item.

For example, a Requisition item type may have a Requisition Approval Process as a top level process. When a particular requisition is created, an application calls CreateProcess to set up the information needed to start the defined process.

Caution: Although you can make a call to CreateProcess() and StartProcess() from a database trigger to initiate a workflow process, you should avoid doing so in certain circumstances. For example, if a database entity has headers, lines and details, and you initiate a workflow process from an AFTER INSERT trigger at the header-level of that entity, your workflow process may fail because some subsequent activity in the process may require information from the entity's lines or details level that is not yet populated.

Attention: The Workflow Engine always issues a savepoint before executing each activity in a process so that it can rollback to the previous activity in case an error occurs. For environments such as database triggers or distributed transactions that do not allow savepoints, the Workflow Engine automatically traps "Savepoint not allowed" errors and defers the execution of the activity. If you initiate a workflow process from a database trigger, the Workflow Engine immediately defers the initial start activities to a background engine, so that they are no longer executing from a database trigger.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type. Item types are defined in the Workflow Builder.
itemkey A string derived usually from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the new process and must be passed to all subsequent API calls for that process.

Note: The item key for a process instance can only contain single-byte characters. It cannot contain a multibyte value.

Note: You can pass #SYNCH as the itemkey to create a forced synchronous process. See: Synchronous, Asynchronous, and Forced Synchronous Processes.

process An optional argument that allows the selection of a particular process for that item. Provide the process internal name. If process is null, the item type's selector function is used to determine the top level process to run. If you do not specify a selector function and this argument is null, an error will be raised.
user_key A user-friendly key to assign to the item identified by the specified item type and item key. This argument is optional.
owner_role A valid role to set as the owner of the item. This argument is optional.

Example

The following code excerpt shows an example of how to call createProcess() in a Java program. The example code is from the WFTest.java program.

// create an item
if (WFEngineAPI.createProcess(ctx, iType, iKey, pr))
  System.out.println("Created Item");
  else
{
  Systm.out.println("createProcess failed");
  WFEngineAPI.showError(ctx);
}

SetItemUserKey

PL/SQL Syntax

procedure SetItemUserKey
  (itemtype in varchar2,
   itemkey in varchar2,
   userkey in varchar2);

Java Syntax

public static boolean setItemUserKey
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String userKey)

Description

Lets you set a user-friendly identifier for an item in a process, which is initially identified by an item type and item key. The user key is intended to be a user-friendly identifier to locate items in the Workflow Monitor and other user interface components of Oracle Workflow.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype or itemType A valid item type.
itemkey or itemKey A string generated usually from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
userkey or userKey The user key to assign to the item identified by the specified item type and item key.

GetItemUserKey

PL/SQL Syntax

function GetItemUserKey
  (itemtype in varchar2,
   itemkey in varchar2)
  return varchar2;

Java Syntax

public static String getItemUserKey
  (WFContext wCtx,
   String itemType,
   String itemKey)

Description

Returns the user-friendly key assigned to an item in a process, identified by an item type and item key. The user key is a user-friendly identifier to locate items in the Workflow Monitor and other user interface components of Oracle Workflow.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype or itemType A valid item type.
itemkey or itemKey A string generated usually from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.

GetActivityLabel

PL/SQL Syntax

function GetActivityLabel
  (actid in number)
  return varchar2;

Description

Returns the instance label of an activity, given the internal activity instance ID. The label returned has the following format, which is suitable for passing to other Workflow Engine APIs, such as CompleteActivity and HandleError, that accept activity labels as arguments:

<process_name>:<instance_label> 

Arguments (input)

Variable Description
actid An activity instance ID.

SetItemOwner

PL/SQL Syntax

procedure SetItemOwner
  (itemtype in varchar2,
   itemkey in varchar2,
   owner in varchar2);

Java Syntax

public static boolean setItemOwner
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String owner)

Description

A procedure to set the owner of existing items. The owner must be a valid role. Typically, the role that initiates a transaction is assigned as the process owner, so that any participant in that role can find and view the status of that process instance in the Workflow Monitor.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type. Item types are defined in the Workflow Builder.
itemkey A string derived from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the new process and must be passed to all subsequent API calls for that process.
owner A valid role.

Example

The following code excerpt shows an example of how to call setItemOwner() in a Java program. The example code is from the WFTest.java program.

// set item owner
if (WFEngineAPI.setItemOwner(ctx, iType, iKey, owner))
  System.out.println("Set Item Owner: "+owner);
else
{
  System.out.println("Cannot set owner.");
  WFEngineAPI.showError(ctx);
}

StartProcess

PL/SQL Syntax

procedure StartProcess
  (itemtype in varchar2,
   itemkey in varchar2);

Java Syntax

public static boolean startProcess
  (WFContext wCtx,
   String itemType,
   String itemKey)

Description

Begins execution of the specified process. The engine locates the activity marked as START and then executes it. CreateProcess() must first be called to define the item type and item key before calling StartProcess().

Caution: Although you can make a call to CreateProcess() and StartProcess() from a trigger to initiate a workflow process, you should avoid doing so in certain circumstances. For example, if a database entity has headers, lines and details, and you initiate a workflow process from an AFTER INSERT trigger at the header-level of that entity, your workflow process may fail because some subsequent activity in the process may require information from the entity's lines or details level that is not yet populated.

Caution: The Workflow Engine always issues a savepoint before executing each activity so that it can rollback to the previous activity in case an error occurs. Because of this feature, you should avoid initiating a workflow process from a database trigger because savepoints and rollbacks are not allowed in a database trigger.

If you must initiate a workflow process from a database trigger, you must immediately defer the initial start activities to a background engine, so that they are no longer executing from a database trigger. To accomplish this:

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string derived from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.

Note: You can pass #SYNCH as the item key to create a forced synchronous process. See: Synchronous, Asynchronous, and Forced Synchronous Processes.

Note: The item key for a process instance can only contain single-byte characters. It cannot contain a multibyte value.

Example

The following code excerpt shows an example of how to call startProcess() in a Java program. The example code is from the WFTest.java program.

// start a process
if (WFEngineAPI.startProcess(ctx, iType, iKey))
  System.out.println("Process Started successfully");
  else
{
  System.out.println("launch failed");
  WFEngineAPI.showError(ctx);
}

LaunchProcess

PL/SQL Syntax

procedure LaunchProcess
  (itemtype in varchar2,
   itemkey in varchar2,
   process in varchar2 default '',
   userkey in varchar2 default '',
   owner in varchar2 default '');

Java Syntax

public static boolean launchProcess
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String process,
   String userKey,
   String owner)

Description

Launches a specified process by creating the new runtime process and beginning its execution. This is a wrapper that combines CreateProcess and StartProcess.

Caution: Although you can make a call to CreateProcess() and StartProcess() from a database trigger to initiate a workflow process, you should avoid doing so in certain circumstances. For example, if a database entity has headers, lines and details, and you initiate a workflow process from an AFTER INSERT trigger at the header-level of that entity, your workflow process may fail because some subsequent activity in the process may require information from the entity's lines or details level that is not yet populated.

Attention: The Workflow Engine always issues a savepoint before executing each activity in a process so that it can rollback to the previous activity in case an error occurs. For environments such as database triggers or distributed transactions that do not allow savepoints, the Workflow Engine automatically traps "Savepoint not allowed" errors and defers the execution of the activity. If you initiate a workflow process from a database trigger, the Workflow Engine immediately defers the initial start activities to a background engine, so that they are no longer executing from a database trigger.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string derived from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the new process and must be passed to all subsequent API calls for that process.

Note: The item key for a process instance can only contain single-byte characters. It cannot contain a multibyte value.

You can pass #SYNCH as the item key to create a forced synchronous process. See: Synchronous, Asynchronous, and Forced Synchronous Processes.

process An optional argument that allows the selection of a particular process for that item. Provide the process internal name. If process is null, the item type's selector function is used to determine the top level process to run. This argument defaults to null.
userkey The user key to assign to the item identified by the specified item type and item key. If userkey is null, then no user key is assigned to the item instance.
owner A valid role designated as the owner of the item. If owner is null, then no owner is assigned to the process and only the workflow administrator role can monitor the process.

SuspendProcess

PL/SQL Syntax

procedure SuspendProcess
  (itemtype in varchar2,
   itemkey in varchar2,
   process in varchar2 default '');

Java Syntax

public static boolean suspendProcess
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String process)

Description

Suspends process execution so that no new transitions occur. Outstanding notifications can complete by calling CompleteActivity(), but the workflow does not transition to the next activity. Restart suspended processes by calling ResumeProcess().

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
process An optional argument that allows the selection of a particular subprocess for that item. Provide the process activity's label name. If the process activity label name does not uniquely identify the subprocess you can precede the label name with the internal name of its parent process. For example:
<parent_process_internal_name>:<label_name>

If this argument is null, the top level process for the item is suspended. This argument defaults to null.

Example

The following code excerpt shows an example of how to call suspendProcess() in a Java program. The example code is from the WFTest.java program.

// suspend, status should become SUSPEND
System.out.println("Suspend Process " + iType +"/"+ iKey +
    " ...");
if (WFEngineAPI.suspendProcess(ctx, iType, iKey, null))
  System.out.println("Seems to suspend successfully");
else
{
  System.out.println("suspend failed");
  WFEngineAPI.showError(ctx);
}

ResumeProcess

PL/SQL Syntax

procedure ResumeProcess
  (itemtype in varchar2,
   itemkey in varchar2,
   process in varchar2 default '');

Java Syntax

public static boolean resumeProcess
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String process)

Description

Returns a suspended process to normal execution status. Any activities that were transitioned to while the process was suspended are now executed.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
process An optional argument that allows the selection of a particular subprocess for that item type. Provide the process activity's label name. If the process activity label name does not uniquely identify the subprocess you can precede the label name with the internal name of its parent process. For example:
<parent_process_internal_name>:<label_name>


If this argument is null, the top level process for the item is resumed. This argument defaults to null.

Example

The following code excerpt shows an example of how to call resumeProcess() in a Java program. The example code is from the WFTest.java program.

// resume process and status should be ACTIVE
System.out.println("Resume Process " + iType +"/"+ iKey +
    " ...");
if (WFEngineAPI.resumeProcess(ctx, iType, iKey, null))
  System.out.println("Seems to resume successfully");
else
{
  System.out.println("resume failed");
  WFEngineAPI.showError(ctx);
}

AbortProcess

PL/SQL Syntax

procedure AbortProcess
  (itemtype in varchar2,
   itemkey in varchar2,
   process in varchar2 default '',
   result in varchar2 default eng_force);

Java Syntax

public static boolean abortProcess
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String process,
   String result)

Description

Aborts process execution and cancels outstanding notifications. The process status is considered COMPLETE, with a result specified by the result argument. Also, any outstanding notifications or subprocesses are set to a status of COMPLETE with a result of force, regardless of the result argument.

This API also raises the oracle.apps.wf.engine.abort event. Although Oracle Workflow does not include any predefined subscriptions to this event, you can optionally define your own subscriptions to this event if you want to perform custom processing when it occurs. See: Workflow Engine Events, Oracle Workflow Developer's Guide and To Define an Event Subscription (for standalone Oracle Workflow), Oracle Workflow Developer's Guide or To Create or Update an Event Subscription (for Oracle Applications), Oracle Workflow Developer's Guide.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
process An optional argument that allows the selection of a particular subprocess for that item type. Provide the process activity's label name. If the process activity label name does not uniquely identify the subprocess you can precede the label name with the internal name of its parent process. For example:
<parent_process_internal_name>:<label_name> 

If this argument is null, the top level process for the item is aborted. This argument defaults to null.
result A status assigned to the aborted process. The result must be one of the values defined in the process Result Type, or one of the following standard engine values:
  • eng_exception
    
  • eng_timeout
    
  • eng_force
    
  • eng_mail
    
  • eng_null
    

This argument defaults to "eng_force".

Example

The following code excerpt shows an example of how to call abortProcess() in a Java program. The example code is from the WFTest.java program.

// abort process, should see status COMPLETE with result 
// code force
System.out.println("Abort Process ..." + iType + "/" + 
    iKey);
if (!WFEngineAPI.abortProcess(ctx, iType, iKey, pr, null))
{
  System.out.println("Seemed to have problem aborting...");
  WFEngineAPI.showError(ctx);
}

CreateForkProcess

PL/SQL Syntax

procedure CreateForkProcess
  (copy_itemtype in varchar2,
   copy_itemkey in varchar2,
   new_itemkey in varchar2,
   same_version in boolean default TRUE);

Description

Forks a runtime process by creating a new process that is a copy of the original. After calling CreateForkProcess(), you can call APIs such as SetItemOwner(), SetItemUserKey(), or the SetItemAttribute APIs to reset any item properties or modify any item attributes that you want for the new process. Then you must call StartForkProcess() to start the new process.

Use CreateForkProcess() when you need to change item specific attributes during the course of a process. For example, if an order cannot be met due to insufficient inventory stock, you can use CreateForkProcess() to fork a new transaction for the backorder quantity. Note that any approval notification will be copied. The result is as if two items were created for this transaction.

Caution: Do not call CreateForkProcess() and StartForkProcess() from within a parallel branch in a process. These APIs do not copy any branches parallel to their own branch that are not active.

Note: When you fork an item, Oracle Workflow automatically creates an item attribute called #FORKED_FROM for the new item and sets the attribute to the item key of the original item. This attribute provides an audit trail for the forked item.

Arguments (input)

Variable Description
copy_itemtype A valid item type for the original process to be copied. The new process will have the same item type.
copy_itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The copy item type and key together identify the original process to be copied.
new_itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and new item key together identify the new process.

Note: The item key for a process instance can only contain single-byte characters. It cannot contain a multibyte value.

same_version Specify TRUE or FALSE to indicate whether the new runtime process uses the same version as the original or the latest version. If you specify TRUE, CreateForkProcess() copies the item attributes and status of the original process to the new process. If you specify FALSE, CreateForkProcess() copies the item attributes of the original process to the new process but does not copy the status. Defaults to TRUE.

StartForkProcess

PL/SQL Syntax

procedure StartForkProcess
  (itemtype in varchar2,
   itemkey in varchar2);

Description

Begins execution of the new forked process that you specify. Before you call StartForkProcess(), you must first call CreateForkProcess() to create the new process. You can modify the item attributes of the new process before calling StartForkProcess().

If the new process uses the same version as the original, StartForkProcess() copies the status and history of each activity in the forked process, activity by activity. If the new process uses the latest version, then StartForkProcess() executes StartProcess().

If you call StartForkProcess() from within a process, any function activity in the process that had a status of 'Active' is updated to have a status of 'Notified'. You must call CompleteActivity() afterwards to continue the process.

StartForkProcess() automatically refreshes any notification attributes that are based on item attributes. Any open notifications in the original process are copied and sent again in the new process. Closed notifications are copied but not resent; their status remains remains 'Complete'.

Any Wait activities in the new process are activated at the same time as the original activities. For example, if a 24 hour Wait activity in the original process is due to be eligible in two hours, the new Wait activity is also eligible in two hours.

Caution: Do not call CreateForkProcess() and StartForkProcess() from within a parallel branch in a process. These APIs do not copy any branches parallel to their own branch that are not active.

Arguments (input)

Variable Description
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process.

Note: The item key for a process instance can only contain single-byte characters. It cannot contain a multibyte value.

Background

PL/SQL Syntax

procedure Background
  (itemtype in varchar2,
   minthreshold in number default null,
   maxthreshold in number default null,
   process_deferred in boolean default TRUE,
   process_timeout in boolean default FALSE,
   process_stuck in boolean default FALSE);

Description

Runs a background engine for processing deferred activities, timed out activities, and stuck processes using the parameters specified. The background engine executes all activities that satisfy the given arguments at the time that the background engine is invoked. This procedure does not remain running long term, so you must restart this procedure periodically. Any activities that are newly deferred or timed out or processes that become stuck after the current background engine starts are processed by the next background engine that is invoked. You can run a script called wfbkgchk.sql to get a list of the activities waiting to be processed by the next background engine run. See: Wfbkgchk.sql, Oracle Workflow Administrator's Guide.

You must not call Background() from within application code. If you want to call this procedure directly, you can run it from SQL*Plus. Otherwise, if you are using the standalone version of Oracle Workflow, you can use one of the sample background engine looping scripts described below, create your own script to make the background engine procedure loop indefinitely, or use the Oracle Workflow Manager component of Oracle Enterprise Manager to schedule a background engine. If you are using the version of Oracle Workflow embedded in Oracle Applications, you can use the concurrent program version of this procedure and take advantage of the concurrent manager to schedule the background engine to run periodically. You can also use the Workflow Manager component of Oracle Applications Manager to submit the background engine concurrent program. See: To Schedule Background Engines, Oracle Workflow Administrator's Guide.

Arguments (input)

Variable Description
itemtype A valid item type. If the item type is null the Workflow engine will run for all item types.
minthreshold Optional minimum cost threshold for an activity that this background engine processes, in hundredths of a second. There is no minimum cost threshold if this parameter is null.
maxthreshold Optional maximum cost threshold for an activity that this background engine processes in hundredths of a second. There is no maximum cost threshold if this parameter is null.
process_deferred Specify TRUE or FALSE to indicate whether to run deferred processes. Defaults to TRUE.
process_timeout Specify TRUE or FALSE to indicate whether to run timed out processes. Defaults to FALSE.
process_stuck Specify TRUE or FALSE to indicate whether to run stuck processes. Defaults to FALSE.

Example Background Engine Looping Scripts

For the standalone version of Oracle Workflow you can use one of two example scripts to run the background engine regularly.

The first example is a SQL script stored in a file called wfbkg.sql in the ORACLE_HOME/wf/admin/sql directory. To run this script, go to the directory where the file is located and type the following command at your operating system prompt:

sqlplus <username/password> @wfbkg <min> <sec> 

Replace <username/password> with the Oracle Database account username and password where you want to run the background engine. Replace <min> with the number of minutes you want the background engine to run and replace <sec> with the number of seconds you want the background engine to sleep between calls.

The second example is a shell script stored in a file called wfbkg.csh in the ORACLE_HOME/bin directory. To run this script, go to the directory where the file is located and type the following command at your operating system prompt:

wfbkg.csh <username/password> 

Replace <username/password> with the Oracle Database account username and password where you want to run the background engine.

AddItemAttribute

PL/SQL Syntax

procedure AddItemAttr
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2,
   text_value in varchar2 default null,
   number_value in number default null, 
   date_value in date default null);

Java Syntax

public static boolean addItemAttr
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String aName)

public static boolean addItemAttrText
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String aName,
   String aValue)

public static boolean addItemAttrNumber
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String aName,
   BigDecimal numberVal)

public static boolean addItemAttrDate
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String aName,
   String aValue)

Description

Adds a new item type attribute variable to the process. Although most item type attributes are defined at design time, you can create new attributes at runtime for a specific process. You can optionally set a default text, number, or date value for a new item type attribute when the attribute is created.

If you are using Java, choose the correct method for your attribute type. To add an empty item type attribute, use addItemAttr(). When adding an item type attribute with a default value, use addItemAttrText() for all attribute types except number and date.

Note: If you need to add large numbers of item type attributes at once, use the AddItemAttributeArray APIs rather than the AddItemAttribute APIs for improved performance. See: AddItemAttributeArray

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java methods only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
aname The internal name of the item type attribute.
text_value The default text value for the item type attribute. Required for the PL/SQL procedure only. Defaults to null.
number_value or numberVal The default number value for the item type attribute. Required for the PL/SQL procedure and addItemAttrNumber() Java method only. Defaults to null.
date_value The default date value for the item type attribute. Required for the PL/SQL procedure only. Defaults to null.
aValue The default value for the item type attribute. Required for the addItemAttrText() and addItemAttrDate() Java methods only.

Example

The following example shows how API calls can be simplified by using AddItemAttr() to set the default value of a new item type attribute at the time of creation.

Using AddItemAttr() to create the new attribute and SetItemAttrText() to set the value of the attribute, the following calls are required:

AddItemAttr('ITYPE', 'IKEY', 'NEWCHAR_VAR');
SetItemAttrText('ITYPE', 'IKEY', 'NEWCHAR_VAR', 
                'new text values');

Using AddItemAttr() both to create the new attribute and to set its value, only the following call is required:

AddItemAttr('ITYPE', 'IKEY', 'NEWCHAR_VAR', 
            'new text values');

AddItemAttributeArray

PL/SQL Syntax

procedure AddItemAttrTextArray
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in Wf_Engine.NameTabTyp,
   avalue in Wf_Engine.TextTabTyp);

procedure AddItemAttrNumberArray
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in Wf_Engine.NameTabTyp,
   avalue in Wf_Engine.NumTabTyp);

procedure AddItemAttrDateArray
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in Wf_Engine.NameTabTyp,
   avalue in Wf_Engine.DateTabTyp);

Description

Adds an array of new item type attributes to the process. Although most item type attributes are defined at design time, you can create new attributes at runtime for a specific process. Use the AddItemAttributeArray APIs rather than the AddItemAttribute APIs for improved performance when you need to add large numbers of item type attributes at once.

Use the correct procedure for your attribute type. All attribute types except number and date use AddItemAttrTextArray.

Note: The AddItemAttributeArray APIs use PL/SQL table composite datatypes defined in the WF_ENGINE package. The following table shows the column datatype definition for each PL/SQL table type.

PL/SQL Table Types in WF_ENGINE
PL/SQL Table Type Column Datatype Definition
NameTabTyp Wf_Item_Attribute_Values.NAME%TYPE
TextTabTyp Wf_Item_Attribute_Values.TEXT_VALUE%TYPE
NumTabTyp Wf_Item_Attribute_Values.NUMBER_VALUE%TYPE
DateTabTyp Wf_Item_Attribute_Values.DATE_VALUE%TYPE

Arguments (input)

Variable Description
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
aname An array of the internal names of the new item type attributes.
avalue An array of the values for the new item type attributes.

SetItemAttribute

PL/SQL Syntax

procedure SetItemAttrText
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2,
   avalue in varchar2);

procedure SetItemAttrNumber
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2,
   avalue in number);

procedure SetItemAttrDate
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2,
   avalue in date);

procedure SetItemAttrEvent
  (itemtype in varchar2,
   itemkey in varchar2,
   name in varchar2,
   event in wf_event_t);

Java Syntax

public static boolean setItemAttrText
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String aName,
   String aValue)

public static boolean setItemAttrNumber
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String aName,
   BigDecimal aValue)

public static boolean setItemAttrDate
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String aName,
   String aValue)

public static boolean setItemAttrDate
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String attributeName,
   java.util.Date attributeValue)

Description

Sets the value of an item type attribute in a process. Use the correct procedure for your attribute type. All attribute types except number, date, and event use SetItemAttrText.

In Java, there are two implementations of setItemAttrDate(). One lets you provide the date value as a Java String object, while the other lets you provide the date value as a Java Date object.

Note: If you need to set the values of large numbers of item type attributes at once, use the SetItemAttributeArray APIs rather than the SetItemAttribute APIs for improved performance. See: SetItemAttributeArray.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
aname, name, or attributeName The internal name of the item type attribute.
avalue, event, or attributeValue The value for the item type attribute.

Examples

Example 1

The following code excerpt shows an example of how to call setItemAttrText() in a Java program. The example code is from the WFTest.java program.

if (WFEngineAPI.setItemAttrText(ctx, iType, iKey, 
    "REQUESTOR_USERNAME", owner))
  System.out.println("Requestor: "+owner);
  else
{
  WFEngineAPI.showError(ctx);
}

Example 2

If an event message is stored within an item attribute of type event, you can access the event data CLOB within that event message by creating an item attribute of type URL for the event data. The following sample PL/SQL code shows how to set the value of the URL attribute in the standalone version of Oracle Workflow to reference the event data.

l_eventdataurl := Wfa_html.base_url||'Wf_Event_Html.
EventDataContents?P_EventAttribute=EVENT_MESSAGE'||'&'||
'P_ItemType='||itemtype||'&'||'P_ItemKey='||itemkey||'&'||
'p_mime_type=text/xml';

WF_ENGINE.SetItemAttrText('<item_type>', '<item_key>', 
          'EVENTDATAURL', l_eventdataurl);

If you have applied a stylesheet to the event data XML document to create HTML, set the p_mime_type parameter in the URL to text/html instead.

If you omit the p_mime_type parameter from the URL, the MIME type defaults to text/xml.

Related Topics

Event Message Structure

setItemAttrFormattedDate

Java Syntax

public static boolean setItemAttrFormattedDate
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String attributeName,
   String attributeValue
   String dateFormat)

Description

Sets the value of an item type attribute of type date in a process with a date value provided as a formatted string.

Arguments (input)

Variable Description
wCtx Workflow context information. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
attributeName The internal name of the item type attribute.
attributeValue The date value for the item type attribute.
dateFormat The format of the date value. The format must be a date format mask that is supported by the Oracle Database. If no format is provided, the default value is the canonical date format for the database. See: Date Formats, Oracle Database Globalization Support Guide.

SetItemAttrDocument

Attention: Document management functionality is reserved for future use. This description of the SetItemAttrDocument API is provided for reference only.

PL/SQL Syntax

procedure SetItemAttrDocument
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2,
   documentid in varchar2);

Java Syntax

public static boolean setItemAttrDocument
  (WFContext wCtx,
   String itemType,
   String itemKey,
   String aName,
   String documentId)

Description

Sets the value of an item attribute of type document, to a document identifier.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
aname The internal name of the item type attribute.
documentid The value for the item type attribute as a fully concatenated string of the following values:
DM:<node_id>:<doc_id>:<version>
  • <node_id> is the node ID assigned to the document management system node as defined in the Document Management Nodes Web page.

  • <doc_id> is the document ID of the document, as assigned by the document management system where the document resides.

  • <version> is the version of the document. If a version is not specified, the latest version is assumed.

SetItemAttributeArray

PL/SQL Syntax

procedure SetItemAttrTextArray
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in Wf_Engine.NameTabTyp,
   avalue in Wf_Engine.TextTabTyp);

procedure SetItemAttrNumberArray
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in Wf_Engine.NameTabTyp,
   avalue in Wf_Engine.NumTabTyp);

procedure SetItemAttrDateArray
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in Wf_Engine.NameTabTyp,
   avalue in Wf_Engine.DateTabTyp);

Description

Sets the values of an array of item type attributes in a process. Use the SetItemAttributeArray APIs rather than the SetItemAttribute APIs for improved performance when you need to set the values of large numbers of item type attributes at once.

Use the correct procedure for your attribute type. All attribute types except number, date, and event use SetItemAttrTextArray.

Note: The SetItemAttributeArray APIs use PL/SQL table composite datatypes defined in the WF_ENGINE package. The following table shows the column datatype definition for each PL/SQL table type.

PL/SQL Table Types in WF_ENGINE
PL/SQL Table Type Column Datatype Definition
NameTabTyp Wf_Item_Attribute_Values.NAME%TYPE
TextTabTyp Wf_Item_Attribute_Values.TEXT_VALUE%TYPE
NumTabTyp Wf_Item_Attribute_Values.NUMBER_VALUE%TYPE
DateTabTyp Wf_Item_Attribute_Values.DATE_VALUE%TYPE

Arguments (input)

Variable Description
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
aname An array of the internal names of the item type attributes.
avalue An array of the values for the item type attributes.

Example

The following example shows how using the SetItemAttributeArray APIs rather than the SetItemAttribute APIs can help reduce the number of calls to the database.

Using SetItemAttrText():

SetItemAttrText('ITYPE', 'IKEY', 'VAR1', 'value1');
SetItemAttrText('ITYPE', 'IKEY', 'VAR2', 'value2');
SetItemAttrText('ITYPE', 'IKEY', 'VAR3', 'value3');

// Multiple calls to update the database.
 

Using SetItemAttrTextArray():

declare
  varname   Wf_Engine.NameTabTyp;
  varval    Wf_Engine.TextTabTyp;
begin
  varname(1) := 'VAR1';
  varval(1)  := 'value1';
  varname(2) := 'VAR2';
  varval(2)  := 'value2';
  varname(3) := 'VAR3';
  varval(3)  := 'value3';
Wf_Engine.SetItemAttrTextArray('ITYPE', 'IKEY', varname, varval);
exception
  when OTHERS then
    // handle your errors here
    raise;
end;

// Only one call to update the database.

getItemTypes

Java Syntax

public static WFTwoDArray getItemTypes
  (WFContext wCtx)

Description

Returns a list of all the item types defined in the Oracle Workflow database as a two-dimensional data object.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.

GetItemAttribute

PL/SQL Syntax

function GetItemAttrText
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2,
   ignore_notfound in boolean default FALSE) 
  return varchar2;

function GetItemAttrNumber
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2,
   ignore_notfound in boolean default FALSE) 
  return number;

function GetItemAttrDate
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2,
   ignore_notfound in boolean default FALSE) 
  return date;

function GetItemAttrEvent
  (itemtype in varchar2,
   itemkey in varchar2,
   name in varchar2) 
  return wf_event_t;

Description

Returns the value of an item type attribute in a process. Use the correct function for your attribute type. All attribute types except number, date, and event use GetItemAttrText.

For GetItemAttrText(), GetItemAttrNumber(), and GetItemAttrDate(), you can specify TRUE for the ignore_notfound parameter to ignore the exception encountered if the specified item type attribute does not exist. In this case the function returns a null value but does not raise an exception. For example, you can use this parameter if a new item type attribute is added to an item type, and your code needs to handle both the earlier version and the upgraded version of the item type.

Arguments (input)

Variable Description
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
aname The internal name of an item type attribute, for GetItemAttrText(), GetItemAttrNumber(), and GetItemAttrDate().
name The internal name of an item type attribute, for GetItemAttrEvent().
ignore_notfound Specify TRUE or FALSE to indicate whether to ignore the exception if the specified item type attribute does not exist, for GetItemAttrText(), GetItemAttrNumber(), and GetItemAttrDate(). If you specify TRUE and the item type attribute you specify does not exist, the function returns a null value but does not raise an exception. Defaults to FALSE.

Related Topics

Event Message Structure

GetItemAttrDocument

Attention: Document management functionality is reserved for future use. This description of the GetItemAttrDocument API is provided for reference only.

PL/SQL Syntax

function GetItemAttrDocument
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2,
   ignore_notfound in boolean default FALSE) 
  return varchar2;

Description

Returns the document identifier for a DM document-type item attribute. The document identifier is a concatenated string of the following values:

DM:<nodeid>:<documentid>:<version>

<nodeid> is the node ID assigned to the document management system node as defined in the Document Management Nodes Web page.

<documentid> is the document ID of the document, as assigned by the document management system where the document resides.

<version> is the version of the document. If a version is not specified, the latest version is assumed.

You can specify TRUE for the ignore_notfound parameter to ignore the exception encountered if the specified item type attribute does not exist. In this case the function returns a null value but does not raise an exception. For example, you can use this parameter if a new item type attribute is added to an item type, and your code needs to handle both the earlier version and the upgraded version of the item type.

Arguments (input)

Variable Description
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
aname The internal name of the item type attribute.
ignore_notfound Specify TRUE or FALSE to indicate whether to ignore the exception if the specified item type attribute does not exist. If you specify TRUE and the item type attribute you specify does not exist, the function returns a null value but does not raise an exception. Defaults to FALSE.

GetItemAttrClob

PL/SQL Syntax

function GetItemAttrClob
  (itemtype in varchar2,
   itemkey in varchar2,
   aname in varchar2) 
  return clob;

Description

Returns the value of an item type attribute in a process as a character large object (CLOB).

Arguments (input)

Variable Description
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
aname The internal name of an item type attribute.

getItemAttributes

Java Syntax

public static WFTwoDArray getItemAttributes
  (WFContext wCtx,
   String itemType,
   String itemKey)

Description

Returns a list of all the item attributes, their types, and their values for the specified item type instance as a two-dimensional data object.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.

GetItemAttrInfo

PL/SQL Syntax

procedure GetItemAttrInfo
  (itemtype in varchar2,
   aname in varchar2,
   atype out varchar2,
   subtype out varchar2,
   format out varchar2);

Description

Returns information about an item type attribute, such as its type and format, if any is specified. Currently, subtype information is not available for item type attributes.

Arguments (input)

Variable Description
itemtype A valid item type.
aname The internal name of an item type attribute.

GetActivityAttrInfo

PL/SQL Syntax

procedure GetActivityAttrInfo
  (itemtype in varchar2,
   itemkey in varchar2,
   actid in number,
   aname in varchar2,
   atype out varchar2,
   subtype out varchar2,
   format out varchar2);

Description

Returns information about an activity attribute, such as its type and format, if any is specified. This procedure currently does not return any subtype information for activity attributes.

Arguments (input)

Variable Description
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
actid The activity ID for a particular usage of an activity in a process definition. Also referred to as the activity ID of the node.
aname The internal name of an activity attribute.

GetActivityAttribute

PL/SQL Syntax

function GetActivityAttrText
  (itemtype in varchar2,
   itemkey in varchar2,
   actid in number,
   aname in varchar2,
   ignore_notfound in boolean default FALSE) 
  return varchar2;

function GetActivityAttrNumber
  (itemtype in varchar2,
   itemkey in varchar2,
   actid in number,
   aname in varchar2,
   ignore_notfound in boolean default FALSE) 
  return number;

function GetActivityAttrDate
  (itemtype in varchar2,
   itemkey in varchar2,
   actid in number,
   aname in varchar2, 
   ignore_notfound in boolean default FALSE) 
  return date;

function GetActivityAttrEvent
  (itemtype in varchar2,
   itemkey in varchar2,
   actid in number,
   name in varchar2) 
  return wf_event_t;

Description

Returns the value of an activity attribute in a process. Use the correct function for your attribute type. If the attribute is a Number or Date type, then the appropriate function translates the number/date value to a text-string representation using the attribute format.

Note: Use GetActivityAttrText() for form, URL, lookup, role, attribute, and document attribute types.

For GetActivityAttrText(), GetActivityAttrNumber(), and GetActivityAttrDate(), you can specify TRUE for the ignore_notfound parameter to ignore the exception encountered if the specified activity attribute does not exist. In this case the function returns a null value but does not raise an exception. For example, you can use this parameter if a new activity attribute is added to an activity, and your code needs to handle both the earlier version and the upgraded version of the activity.

Arguments (input)

Variable Description
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
actid The activity ID for a particular usage of an activity in a process definition. Also referred to as the activity ID of the node.
aname The internal name of an activity attribute, for GetActivityAttrText(), GetActivityAttrNumber(), and GetActivityAttrDate().
name The internal name of an activity attribute, for GetActivityAttrEvent().
ignore_notfound Specify TRUE or FALSE to indicate whether to ignore the exception if the specified activity attribute does not exist, for GetActivityAttrText(), GetActivityAttrNumber(), and GetActivityAttrDate(). If you specify TRUE and the activity attribute you specify does not exist, the function returns a null value but does not raise an exception. Defaults to FALSE.

Related Topics

Event Message Structure

GetActivityAttrClob

PL/SQL Syntax

function GetActivityAttrClob
  (itemtype in varchar2,
   itemkey in varchar2,
   actid in number,
   aname in varchar2) 
  return clob;

Description

Returns the value of an activity attribute in a process as a character large object (CLOB).

Arguments (input)

Variable Description
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
actid The activity ID for a particular usage of an activity in a process definition. Also referred to as the activity ID of the node.
aname The internal name of an activity attribute.

getActivityAttributes

Java Syntax

public static WFTwoDArray getActivityAttributes
  (WFContext wCtx,
   String itemType,
   String itemKey,
   BigDecimal actID)

Description

Returns a list of all the activity attributes, their types, and their values for the specified activity as a two-dimensional data object.

Arguments (input)

Variable Description
wCtx Workflow context information. Required for the Java method only. See: Oracle Workflow Context.
itemtype A valid item type.
itemkey A string generated from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: