Вы находитесь на странице: 1из 50

1 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Oracle Workflow
Workbook
Version 1.0


2 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Table of contents
INTRODUCTION TO ORACLE WORKFLOW 4
Routing Information 4
Defining and Modifying Business Rules 4
Delivering Electronic Notifications 4
Integrating Systems 4
MAJOR FEATURES AND DEFINITIONS 5
Oracle Workflow Builder 5
Workflow Engine 5
Business Event System 5
Workflow Definitions Loader 5
Complete Programmatic Extensibility 6
Electronic Notifications 6
Electronic Mail Integration 6
Internet-Enabled Workflow 6
Monitoring and Administration 6
Workflow types 7
WORKFLOW ARCHITECTURE 8
Various components and their purpose 8
Workflow Definition Loader 8
Oracle Workflow Builder 8
PL/SQL Extendibility 8
Monitoring and Administration 9
Electronic Notifications 9
Workflow Background Engine 9
Notifications 9
Lookup Types 9
Process 9
Messages 9
Attributes 10
Functions 11
VERSIONABLE AND NON-VERSIONAL ORACLE WORKFLOW COMPONENTS
13
Versionable components of Oracle Workflow 13
Non-Versionalble components 13
STRUCTURE OF PLSQL CALLED BY ORACLE WORKFLOW 14
EXAMPLES 1: A SIMPLE NOTIFICATION TO A USER 15
CREATING A WORKFLOW PROCESS 19
STARTING A WORKFLOW PROCESS 21
PL/SQL Syntax 21
Java Syntax 21
Description 21
Arguments (input) 21
EXAMPLE 2: SENDING NOTIFICATION TO ANY USER 23
EXAMPLE 3: SENDING A LEAVE REQUEST NOTIFICATION 26
USING SETITEMATTRXXX() AND GETITEMATTRXXX() 31
EXAMPLE 4: RECEIVING A REMARK FROM THE END USER 33
EXAMPLE 5: PROVIDE A DROPDOWN LIST TO THE END USER 35
EXAMPLE 6: USING VOTING ACTIVITY 37
EXAMPLE 7: EVENTS IN ORACLE WORKFLOW 38

3 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

EXAMPLE 8: SENDING NOTIFICATION TO MULTIPLE USERS 43



4 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Introduction to Oracle Workflow
Business processes today involve getting many types of information to multiple people
according to rules that are constantly changing. Oracle Workflow lets you automate and
continuously improve business processes, routing information of any type according to
business rules you can easily change to people both inside and outside your enterprise.
Routing Information
With so much information available, and in so many different forms, how do you get the
right information to the right people? Oracle Workflow lets you provide each person with
all the information they need to take action. Oracle Workflow can route supporting
information to each decision maker in a business process.
Defining and Modifying Business Rules
Oracle Workflow lets you define and continuously improve your business processes using a
drag-and-drop process designer.
Unlike workflow systems that simply route documents from one user to another with some
approval steps, Oracle Workflow lets you model sophisticated business processes. You can
define processes that loop, branch into parallel flows and then rendezvous, decompose
into subflows, and more. Because Oracle Workflow can decide which path to take based on
the result of a stored procedure, you can use the full power of PL/SQL, the language of the
Oracle database server, to express any business rule that affects a workflow process.
Delivering Electronic Notifications
Oracle Workflow extends the reach of business process automation throughout the
enterprise and beyond to include any e-mail or Internet user. Oracle Workflow lets people
receive notifications of items awaiting their attention via e-mail, and act based on their e-
mail responses. You can even view your list of things to do, including necessary supporting
information, and take action using a standard Web browser.
Integrating Systems
Oracle Workflow lets you set up subscriptions to business events which can launch
workflows or enable messages to be propagated from one system to another when
business events occur. You can communicate events among systems within your own
enterprise and with external systems as well. In this way, you can implement point-to-point
messaging integration or use Oracle Workflow as a messaging hub for more complex
system integration scenarios. You can model business processes that include complex
routing and processing rules to handle events powerfully and flexibly.

5 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Major Features and Definitions
Oracle Workflow Builder
Oracle Workflow Builder lets you create, view, or modify a business process with simple
drag and drop operations. Using the Workflow Builder, you can create and modify all
workflow objects, including activities, item types, and messages.
At any time you can add, remove, or change workflow activities, or set up new prerequisite
relationships among activities. You can easily work with a summary-level model of your
workflow, expanding activities within the workflow as needed to greater levels of detail.
And, you can operate Oracle Workflow Builder from a desktop PC or from a disconnected
laptop PC.
Workflow Engine
The Workflow Engine embedded in the Oracle database server monitors workflow states
and coordinates the routing of activities for a process. Changes in workflow state, such as
the completion of workflow activities, are signaled to the engine via a PL/SQL API or a Java
API. Based on flexibly-defined workflow rules, the engine determines which activities are
eligible to run, and then runs them. The Workflow Engine supports sophisticated workflow
rules, including looping, branching, parallel flows, and subflows.
Business Event System
The Business Event System is an application service that uses the Oracle Advanced Queuing
(AQ) infrastructure to communicate business events between systems. The Business Event
System consists of the Event Manager, which lets you register subscriptions to significant
events, and event activities, which let you model business events within workflow
processes.
When a local event occurs, the subscribing code is executed in the same transaction as the
code that raised the event. Subscription processing can include executing custom code on
the event information, sending event information to a workflow process, and sending
event information to other queues or systems.
Workflow Definitions Loader
The Workflow Definitions Loader is a utility program that moves workflow definitions
between database and corresponding flat file representations. You can use it to move
workflow definitions from a development to a production database, or to apply upgrades
to existing definitions. In addition to being a standalone server program, the Workflow
Definitions Loader is also integrated into Oracle Workflow Builder, allowing you to open
and save workflow definitions in both a database and file.

6 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Complete Programmatic Extensibility
Oracle Workflow lets you include your own PL/SQL procedures or external functions as
activities in your workflows. Without modifying your application code, you can have your
own program run whenever the Workflow Engine detects that your program's
prerequisites are satisfied.
Electronic Notifications
Oracle Workflow lets you include users in your workflows to handle activities that cannot
be automated, such as approvals for requisitions or sales orders. Electronic notifications
are routed to a role, which can be an individual user or a group of users. Any user
associated with that role can act on the notification.
Each notification includes a message that contains all the information a user needs to make
a decision. The information may be embedded in the message body or attached as a
separate document. Oracle Workflow interprets each notification activity response to
decide how to move on to the next workflow activity.
Electronic Mail Integration
Electronic mail (e-mail) users can receive notifications of outstanding work items and can
respond to those notifications using their e-mail application of choice. An e-mail
notification can include an attachment that provides another means of responding to the
notification.
Internet-Enabled Workflow
Any user with access to a standard Web browser can be included in a workflow. Web users
can access a Notification Web page to see their outstanding work items, then navigate to
additional pages to see more details or provide a response.
Monitoring and Administration
Workflow administrators and users can view the progress of a work item in a workflow
process by connecting to the Workflow Monitor using a standard Web browser that
supports Java. The Workflow Monitor displays an annotated view of the process diagram
for a particular instance of a workflow process, so that users can get a graphical depiction
of their work item status. The Workflow Monitor also displays a separate status summary
for the work item, the process, and each activity in the process.
If you are using the version of Oracle Workflow embedded in Oracle Applications and you
have implemented Oracle Applications Manager, you can also use the Oracle Workflow
Manager component of Oracle Applications Manager as an additional administration tool
for Oracle Workflow. Oracle Applications Manager is a tool that provides administrative
and diagnostic capabilities for concurrent processing, Oracle Workflow, and other
functionality in Oracle Applications. For more information, please refer to the Oracle
Applications Manager online help.

7 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Workflow types
There are 2 types of workflows.
1. Traditional Workflows
2. Event based Workflows
A traditional workflow usually looks like

It only consists of applications integrated through some mechanishm where each step in
the workflow runs one after the other without any timegap. This model is not applicable to
the modern business where the processes have very complex and frequently modifiable in
nature.
That is where the need of event based workflows came into existence.

In this model, the Business event system offers additional fecitiles like waiting for end user
response independent of time. Resuming the process based on the response received etc.
This model is the most interesting and useful model.
Oracle Workflow provides facilities to implement Business Event based Workflows.


8 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Workflow Architecture
Oracle workflow is a combination of various components that can be classified into 4 parts.
1. End-user client
2. Application Server
3. Oracle Database
4. Development cycle
The following picuture will show the components of a Oracle workflow system.

Various components and their purpose
Workflow Definition Loader
A utility program that moves workflow definitions between database and corresponding
flat file representations. When a workflow definintion is saved in the local disk, it gets
stored in XML format. But he same workflow when stored in the database, the definition
loader translates that XML definitions and stores them in the tables of the backend
database.
Oracle Workflow Builder
This is a graphical tool that lets you create, view, or modify a business process with simple
drag and drop operations. Also helps quick modification of the existing workflow
definitions.
PL/SQL Extendibility
Oracle Workflow lets you include your own PL/SQL procedures or external functions as
activities in your workflow. Through this procedure we can call a plsql procedure or a java
program to run as activity in workflow.

9 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Monitoring and Administration
Oracle workflow system provides GUI bawsed workflow management system. Through this
we can view existing workflows in execution. Helps management of such workflow to stop,
restart or to monitor such workflow.
Electronic Notifications
There are systems in which a workflow may require input from a human. Electronic
notification helps us to send information to a user and wait for his/her response and then
continue the workflow execution.
Workflow Background Engine
This is the most important component of the workflow system. Monitors workflow states
and coordinates the routing of activities for a process. Each in stance of the workflow is
created, executed and terminated by this engine.
Notifications
A notification activity sends a message to a performer.
Lookup Types
A lookup type provides a static list of values. These lists can be referenced by activities and
by item type, message or activity attributes. They are used in situations where decision
making is needed based on a response.
There are different types of look types predefined in the Oracle workflow.
Process
Oracle Workflow manages business processes according to rules that you define. The rules,
which we call a workflow process definition, include the activities that occur in the process
and the relationship between those activities. An activity in a process definition can be an
automated function defined by a PL/SQL stored procedure, a notification to a user or role
that may optionally request a response or a sub-flow that itself is made up of a more
granular set of activities.
Messages
A Message is a text with dynamic data that is delivered throgh notification to a user(s).
They can be static and interactive also. These messages can carry any type of information
such as text field, Combo box etc.

10 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Attributes
Attributes of Oracle workflow helps data exchange between the environment and
workflow. Also it helps data availability through the workflow. They act as a global variable
that can be referenced or updated by any activity within a process.
Oracle workflow engine provides procecedures such as setItemAttrXXX() and
getItemAttrXXX() methods to store or retrieve data using these variables respectively. Here
XXX refers to the type of attribute.
There are various attribute types. Details are given in the below table
Attribute Type Description
Text The attribute value is a string of text.
Number The attribute value is a number with the optional format mask you
specify
Date The attribute value is a date with the optional format mask you
specify
Lookup The attribute value is one of the lookup code values in a specified
lookup type
Form The attribute value is an Oracle Applications internal form function
name and its optional form function parameters
URL The attribute value is a Universal Resource Locator (URL) to a network
location.
Document The attribute value is an attached document. You can specify the
following types of documents in the default value field
Document
type
Purpose
PL/SQL A document representing data from the database
as a character string, generated from a PL/SQL
procedure
PL/SQL
CLOB
A document representing data from the database
as a character large object (CLOB), generated
from a PL/SQL procedure
PL/SQL
BLOB
a document representing data from the database
as a binary large object (BLOB), generated from a
PL/SQL procedure
Role The attribute value is the internal name of a role. If a message
attribute of type role is included in a notification message, the
attribute automatically resolves to the roles display name,
eliminating the need for you to maintain separate attributes for the
roles internal and display names.
Attribute
The attribute value is the internal name of another existing item type
attribute that you want to maintain references to in a process
Event
The attribute value is a Business Event System event message in the
standard WF_EVENT_T structure.

11 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Functions
A workflow consists of various nodes. Each node is associated with a function. A function
many be executing a PLSQL procedur, calling a java program or executing any other
command that is allowed by Oracle workflow.
Function mode
A function mode is a mode of execution which will be initiated by the workflow engine the
moment an oracle application user processes certain function or notification activity.
The function modes of executing a function activity differ from a notification activity.
With the help of function modes a user can actually get the control over executing different
types of operations depending on the user response to the notification
Function modes of a function activity
If the activity is function activity it has only two function modes they are
1. RUN
2. CANCEL
Function modes of a notification activity
The following are some of the list of function modes that a notification activity gets
executed in
1. RUN
2. RESPOND
3. FORWARD
4. TRANSFER
5. TIMEOUT.
RUN
If a notification is sent to single or multiple users or if the function activity is executed and
if the notification or a function is processed then the notification or a function activity will
be executed in RUN mode.
For every successful processing of a notification by a oracle application user the notification
will be executed in RUN function mode
RESPOND
This type of function mode is initiated only in the case of a notification activity.

12 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

A notification will be executed in a respond mode only if a oracle application user is asked
to give the response through the associated message attributes created with respond as
the source.
FORWARD
If a notification is been delegated to another oracle application user or a group of oracle
application users (role) then the notification gets executed in FORWARD mode.
Immediately the notification gets executed in RUN mode after FORWARD mode.
This type of function mode is initiated only in the case of a notification activity.
TRANSFER
The notification activity gets executed in TRANSFER mode only if the ownership if
transferred to different oracle application user or a role.
The moment the ownership the transferred the new owner has the all the privileges to
process the notification.
This type of function mode is initiated only in the case of a notification activity.
TIMEOUT
If the notification activity is timed out then TIMEOUT mode gets initiated.
This type of function mode is initiated only in the case of a notification activity.
QUESTION
If more information about a particular notification is requested by the recipient of the
notification then the notification is executed in QUESTION mode.
We cannot request the information from the user to whom we send the notification.
Immediately the notification gets executed in RUN mode after QUESTION mode.
This type of function mode is initiated only in the case of a notification activity.
ANSWER
If more information is requested by the recipient of the notification and if the other user
responds to the request then the notification is executed in ANSWER mode.
This type of function mode is initiated only in the case of a notification activity.


13 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Versionable and Non-versional oracle workflow components
When you create a process definition, Oracle Workflow Builder assigns a new version
number to an activity if you make changes to it. It saves the new version of the activity to
the database without overwriting older versions of the activity.
In Oracle Workflow, activities also have dates of effectivity so that at any point in time, only
one version of the activity is "in effect". If a process is running, Oracle Workflow uses the
version of the activity that was in effect when the process was initiated. It does not switch
versions of the activity mid-way through the process. Note that a process itself is an
activity, so a process definition always remains constant until the process instance
completes.
When a user make changes to the existing workflow, a new version is created and stored in
the database automatically. But not all the coponents of a work flow are versioned. So if we
make changes to the components that are not varsionable, so the latest changes will be
applied to the old workflows also.
So we need to take care while making changes to the workflow.
Versionable components of Oracle Workflow
1. Notifications
2. Functions
3. Events
4. Processes and subprocesses
5. Process activities (nodes)
6. Activity attributes
7. Activity attribute values
8. Activity transitions
Non-Versionalble components
1. Item attributes
2. Messages
3. Lookups
4. PL/SQL code referenced by function activities


14 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Structure of PLSQL called by Oracle Workflow
A PLSQL procedure is a very important component which can be called into oracle
workflow through functions. So, any task related to database or any external functionality
such as calling a web program etc can be achieved.
The complete structure of the procedure is given below.
procedure <procedure name> (
itemtype in varchar2,
itemkey in varchar2,
actid in number,
funcmode in varchar2,
resultout out varchar2)
is
<local declarations>
begin
if ( funcmode = RUN ) then
<your RUN executable statements>
resultout := COMPLETE:<result>;
return;
end if;
if ( funcmode = CANCEL ) then
<your CANCEL executable statements>
resultout := COMPLETE;
return;
end if;
if ( funcmode = RESPOND ) then
<your RESPOND executable statements>
resultout := COMPLETE;
return;
end if;
if ( funcmode = FORWARD ) then
<your FORWARD executable statements>
resultout := COMPLETE;
return;
end if;
if ( funcmode = TRANSFER ) then
<your TRANSFER executable statements>
resultout := COMPLETE;
return;
end if;
if ( funcmode = TIMEOUT ) then
<your TIMEOUT executable statements>
if (<condition_ok_to_proceed>) then
resultout := COMPLETE;
else
resultout := wf_engine.eng_timedout;
end if;
return;
end if;
if ( funcmode = <other funcmode> ) then
resultout := ;
return;
end if;
exception
when others then
WF_CORE.CONTEXT (<package name>, <procedure name>, <itemtype>,
<itemkey>, to_char(<actid>), <funcmode>);
raise;
end <procedure name>;

15 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Examples 1: A Simple Notification to a user
Create a new Item type in the workflow
Internal name : EXAMPLE1
Display Name : EXAMPLE1
Create a New message to be sent
In the Message tab:
Internal Name : MESSAGE1
Display Name : MESSAGE1
In the Body tab:
Body type : Text body
Message : HELLO FRIENDS HOW ARE YOU ?
Create a notification:
Internal Name : NOTIFICATION1
Display Name : NOTIFICATION1
Message : Select the message name created in the previous step
Create a Function:
Internal Name : START
Display Name : START
Function Name : WF_STANDARD.NOOP
Create another function
Internal Name : END
Display Name : END
Function Name : WF_STANDARD.NOOP
Create a process:
Internal Name : PROCESS1
Display Name : PROCESS1
Runnable : Checked
So the Navigator looks as below

16 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s


Start defininig your workflow:
3. Double click on the process
4. Drag and drop both start and end functions on the process window
5. Drag and drop the notification on the process window
6. Right click on the Start and hold. Drag mouse and drop on the Notification.
7. Repeat the above step between Notificaiton and End function
8. Your Work looks as shown below



17 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Setup the properties of Notification in the process window.
Double click on the notification and specify the following properties in Node tab.


Setup up properties of Start function in the process window
Double click on the Start and specify the following properties in Node tab.

Setup up properties of End function in the process window
Double click on the End and specify the Start/End property to End in the node Node tab as
shown for the Start.
Your workflow in now ready. Now save it in the database.
Test your workflow
Create an anonymous plsql block from the backend.
User name to whom
you want to send the
message
Change to Start

18 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

BEGIN
WF_ENGINE.CREATEPROCESS(EXAMPLE1,1,PROCESS1);
WF_ENGINE.STARTPROCESS(EXAMPLE1,1);
COMMIT;
END;
Login in to the apps user which was the performer of your notification, in our example
USER_98558.


19 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Creating a workflow process
A Workflow process can be instantiated from either a PLSQL program or a Java Program.
Syntaes as given below.
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 instance 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.
Important: 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.
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

20 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

characters. It cannot contain a multibyte value.
Note: You can pass #SYNCH as the itemkey to create a forced synchronous
process.
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.



21 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Starting a workflow Process
A workflow process instance can be created only once. But we can start it any number of
times in a sequential order.
To start a workflow process, we have methods designed.
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().
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:
Set the cost of the process start activities to a value greater than the Workflow Engine
threshold (default value is 0.5)
or
Set the Workflow Engine threshold to be less than 0 before initiating the process:
begin
save_threshold := WF_ENGINE.threshold;
WF_ENGINE.threshold := -1;
WF_ENGINE.CreateProcess(...);
WF_ENGINE.StartProcess(...);
--Always reset threshold or all activities in this
--session will be deferred.
WF_ENGINE.threshold := save_threshold;
end
Arguments (input)

22 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Variable Description
wCtx Workflow context information. Required for the Java method only.
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.



23 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Example 2: Sending notification to any user
In this example we would demonstrate how to supply values required to a workflow at the
time starting process. In this example we will learn another method of creating a workflow
using Quick Start Wizard.
Create a new Item type in the workflow
File -> Quick Start wizard
New Item type
Internal Name : EXAMPLE2
Display Name : EXAMPLE2
New Process type
Internal Name : PROCESS2
Display Name : PROCESS2



You can observe that a Item type EXAMPLE2 and another ITEM type Standard are
automatically created with a process having START and END functions automatically placed.
The Standard Item type consists of various predefined notifications, Functions, Message,
Lookup types which can be reused in your current Workflow design. Actually the Start and
the End functions placed in the workflow are from standard only.

24 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Note: Study the properties automatically setup for these items.
Create Required Attributes
Attribute1:
Internal Name : USERNAME
Display Name : USERNAME
Type : Text
Default type : Constant
Default Value : Will be assigned at run time
Attribute 2:
Internal Name : MSGTODISPLAY
Display Name : MSGTODISPLAY
Type : Text
Default type : Constant
Default Value : Will be assigned at run time
Create a New message to be sent
In the Message tab:
Internal Name : MESSAGE1
Display Name : MESSAGE1
In the Body tab:
Body type : Text body
Message : &MSGTODISPLAY (To take text of the attribute)
Create a notification:
Internal Name : NOTIFICATION1
Display Name : NOTIFICATION1
Message : Select the message name created in the previous step(MESSAGE1)

Associtate the required attributes to the activities
1. Drag USERNAME attribute and drop it under NOTIFICATION1
2. Drag MSGTODIPLAY attribute and drop it under MESSAGE1
So our Navigator should look as follows.

25 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s


Start defininig your workflow:
1. Drag and drop the notification on the process window
9. Right click on the Start and hold. Drag mouse and drop on the Notification.
10. Repeat the above step between Notificaiton and End function
11. Your Work looks as shown below
Setup the properties of Notification in the process window.
Double click on the notification and specify the following properties in Node tab.
Performer Type : Attribute
Performer Value : USERNAME
Save your workflow in the backend.
Test your workflow
Create an anonymous plsql block from the backend.
BEGIN
WF_ENGINE.CREATEPROCESS(EXAMPLE2,1,PROCESS2);
--Here we are supplying the values to attributes USERNAME and MSGTODISPLAY
WF_ENGINE.SETITEMATTRTEXT(EXAMPLE1,1,USERNAME,USER_98558);
WF_ENGINE.SETITEMATTRTEXT(EXAMPLE1,1,MSGTODISPLAY,Hello dear USER_98558,
Welcome to Oracle workflow attribute setting);
WF_ENGINE.STARTPROCESS(EXAMPLE2,1);
COMMIT;
END;
Login in to the apps user which was the performer of your notification ie USER_98558.


26 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Example 3: Sending a Leave request Notification
Consider a business requirement in which a person applies for a leave it should go his/her
supervisor for approval and once it is approved save the information in database (say in
custom table*). If the leave gets rejected, dont store any information in database.
Below are the workflow components needed to implement a solution for the above. In this
we are just sending information to the Supervisor but not storing any information in the
database.
Create a workflow using Quick Start Wizard
Specify below attributes for Item Type
Internal Name : LEAVEAPP
Display Name : Leave Application Information
Specify below attributes for New Process
Internal Name : LEAVEPROCESS
Display Name : Leave application information process
Create required Attributes
Attribute 1:
Internal Name : REQUESTOREMPID
Display Name : Requestor Employee ID
Type : Number
Value : Will be supplied at Runtime
Attribute 2:
Internal Name : REQUESTORNAME
Display Name : Requestor Employee name
Type : Text
Value : Will be supplied at Runtime
Attribute 3:
Internal Name : LEAVETYPE
Display Name : Type of leave applied
Type : Text
Value : Will be supplied at Runtime
Attribute 4:
Internal Name : LEAVEFROMDATE

27 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Display Name : Leave start date
Type : Date
Value : Will be supplied at Runtime
Attribute 5:
Internal Name : LEAVETODATE
Display Name : Leave end date
Type : Date
Value : Will be supplied at Runtime
Attribute 6:
Internal Name : RMLOGINID
Display Name : Reporting manager user id
Type : Text
Value : Will be supplied at Runtime
If you check the standard item type created, you will find a LOOK TYPE named
WFSTD_APPROVAL(Approval) with 2 lookup codes created. We can use them in this
example.
Create a message
Internal Name : MSGTORM
Display Name : Message to the supervisor
Type : Text
Value :
Dear Supervisor,

Your reportee &REQUESTORNAME (ID: &REQUESTOREMPID) has appled for a &LEVETYPE type of
leave from &LEAVESTARTDATE to &LEAVETODATE.

Request your attention and take necessary action.

Note: Please do not reply to thismail.

Drag and Drop all attributes from Attributes node to Message node. Now double click on
any Attribute below message, you will find a new attribute name "Source" with a value
"Send". That means this value is passed from work flow to the end user.
Provide a facility to Supervisor to Accept or Reject the leave application
Double click on the message. Go to Result Tab in the dialog box.
Display name : Approve/Reject
Lookup type : Approval
Create a notification

28 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Internal Name : LEAVENOTIFICATION
Display Name : Leave notification
Result type : Approval
Message : Message to the supervisor
Drag and Drop the RMLOGINID from Attributes node to LEVENOTIFICATION
Create a table in which this information need to be captured in the apps schema
CREATE TABLE dummyEmployee(
empid NUMBER,
empname VARCHAR2(20),
leavetype VARCHAR2(20),
leavefrom DATE,
leaveto DATE,
rmusername VARCHAR2(20)
approvaldate DATE
)
Create a procedure that gets executed when leave gets approved
Any procedure that is called into the Workflow should have 5 parameters as given in the
below procedure.
Item type is the name of item type. In our calse LEAVEAPP
ItemKey is the serial number passed while creating the workflow process
These are the 2 important attributes to get remaining information
CREATE OR REPLACE PROCEDURE storedata (
ITEMTYPE IN VARCHAR2,
ITEMKEY IN VARCHAR2,
ACTID IN NUMBER,
FUNCMODE IN VARCHAR2,
RESULTOUT OUT VARCHAR2)
IS
V_EMPID NUMBER;
V_EMPNAME VARCHAR2(20);
V_LEAVETYPE VARCHAR2(20);
V_LEAVEFROM DATE;
V_LEAVETO DATE;
V_RMUNAME VARCHAR2(20);
BEGIN
V_EMPID := WF_ENGINE.getitemattrnumber(ITEMTYPE, ITEMKEY, 'REQUESTOREMPID');
V_EMPNAME := WF_ENGINE.GETITEMATTRTEXT (ITEMTYPE,ITEMKEY,'REQUESTOREMPNAME');
V_LEAVETYPE := WF_ENGINE.GETITEMATTRTEXT(ITEMTYPE,ITEMKEY, 'LEVETYPE');
V_LEAVEFROM := wf_engine.getitemattrdate(ITEMTYPE, ITEMKEY, 'LEAVEFROMDATE');
V_LEAVETO := wf_engine.getitemattrdate(ITEMTYPE, ITEMKEY, 'LEAVETODATE');
V_RMUNAME := wf_engine.getitemattrdate(ITEMTYPE, itemkey, 'RMLOGINID');
INSERT
INTO dummyemployee VALUES(V_EMPID, v_empname, v_leavetype, v_leavefrom, v_leaveto,
v_rmuname, sysdate);
COMMIT;
END;
Create a function for PLSQL procedure execution
Internal Name : STOREDATA
Display Name : To store data in table

29 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Function name : STOREDATE (name of the plsql procedure. Need not be same as internal
name)
Function type : PL/SQL
Now we are ready with the components needed to implement our process. Double click on
the process to open the process window. Start and End functions are already present.
Now perform the following steps to complete your workflow
1. Drag and drop your notification in the Process window from the navigator.
2. Double click on the Notification in the process window.
3. Goto Node tab and set the Performer type to "Item Attribute" and Perform value to
"Reporting manager user id".
4. Drag and drop the STOREDATA function from Navigator to the Process window.
5. Hold mouse right button on Start. Drag and release it on Notification.
6. Hold mouse right button on the Notification. Drag and release on the STOREDATA
function.
7. You get a List of Lookup values. Select Approve.
8. Hold mouse right button on the STARTDATA function. Drag and release on End.
9. Again Hold mouse right button on the Notification. Drag and release on the End.
10. It displays again a list of options from which select Reject.
Your workflow should look as given below

Test your workflow
Login to the backend and run the below procedure
BEGIN
WF_ENGINE.CREATEPROCESS('LEAVEAPP',1,'LEAVEPROCESS');
WF_ENGINE.setitemattrnumber('LEAVEAPP',1,'REQUESTOREMPID','100');

30 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

WF_ENGINE.setitemattrtext('LEAVEAPP',1,'REQUESTOREMPNAME','RAMA');
WF_ENGINE.setitemattrtext('LEAVEAPP',1,'LEVETYPE','EARNED');
wf_engine.setitemattrdate('LEAVEAPP',1,'LEAVEFROMDATE','10-JUN-14');
wf_engine.setitemattrdate('LEAVEAPP',1,'LEAVETODATE','11-JUN-14');
wf_engine.setitemattrtext('LEAVEAPP',1,'RMLOGINID','USER_98558');
WF_ENGINE.startprocess('LEAVEAPP',1);
COMMIT;
END;
You will find output as given below.
Test the table for the newly inserted row.




31 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Using SetItemAttrXXX() and GetItemAttrXXX()
Depending on the type of attribute, one can send values from execution environment to
the Workflow as well as retrieve values of the attributes during execution of the workflow.
Set methods are used for sending data from environment to workflow
Get methods are used for retrieving data from workflow
Depending on the attribute types, work flow has various methods as given below
Set Methods
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 varchar2
);
procedure SetItemAttrDate (
itemtype in varchar2,
itemkey in varchar2,
aname in varchar2,
avalue in varchar2
);
procedure SetItemAttrEvent (
itemtype in varchar2,
itemkey in varchar2,
aname in varchar2,
avalue in varchar2
);

procedure SetItemAttrDocument (
itemtype in varchar2,
itemkey in varchar2,
aname in varchar2,
avalue in varchar2
);
Get Methods
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,

32 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

aname in varchar2,
ignore_notfound in boolean default FALSE
) return Date;

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

function GetItemAttrDocument
itemtype in varchar2,
itemkey in varchar2,
aname in varchar2,
ignore_notfound in boolean default FALSE
) return varchar2;
Other methods are also present using which we can set and get other values.

33 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Example 4: Receiving a remark from the End user
Now letus change our above exercise in such a way that we send a text box to the
Supervisor/RM. While accepting, supervisor will provide comments. Those comments need
to be saved in the table.
Changes needed to the table
ALTER TABLE dummyEmployee ADD(status CHAR, remarks VARCHAR2(200));
Create a new Attribute
Internal Name : COMMENT
Display Name : Supervisor Comment
Length : 200 (Please make sure that this length is equal or smaller than column length)
Drag and Drop the supervisor comment under Message (MSGTORM)
Double click on the COMMENT attribute under Message
You will find a new attribute "Source" with value as "Send". Change that value to respond.
Modify your procedure
CREATE OR REPLACE
PROCEDURE storedata
(
ITEMTYPE IN VARCHAR2,
ITEMKEY IN VARCHAR2,
ACTID IN NUMBER,
FUNCMODE IN VARCHAR2,
RESULTOUT OUT VARCHAR2)
IS
V_EMPID NUMBER;
V_EMPNAME VARCHAR2(20);
V_LEAVETYPE VARCHAR2(20);
V_LEAVEFROM DATE;
V_LEAVETO DATE;
V_RMUNAME VARCHAR2(20);
V_COMMENT VARCHAR2(200);
BEGIN
V_EMPID := WF_ENGINE.getitemattrnumber(ITEMTYPE, ITEMKEY, 'REQUESTOREMPID');
V_EMPNAME := WF_ENGINE.GETITEMATTRTEXT (ITEMTYPE,ITEMKEY,'REQUESTOREMPNAME');
V_LEAVETYPE := WF_ENGINE.GETITEMATTRTEXT(ITEMTYPE,ITEMKEY, 'LEVETYPE');
V_LEAVEFROM := wf_engine.getitemattrdate(ITEMTYPE, ITEMKEY, 'LEAVEFROMDATE');
V_LEAVETO := wf_engine.getitemattrdate(ITEMTYPE, ITEMKEY, 'LEAVETODATE');
V_RMUNAME := wf_engine.getitemattrdate(ITEMTYPE, itemkey, 'RMLOGINID');
v_comment := wf_engine.getitemattrtext(ITEMTYPE, ITEMKEY, 'COMMENTS');
INSERT
INTO dummyemployee VALUES(V_EMPID, v_empname, v_leavetype, v_leavefrom, v_leaveto,
v_rmuname, sysdate,'A',v_comment);
COMMIT;
END;
Test your workflow
Login to the backend and run the below procedure

34 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

BEGIN
WF_ENGINE.CREATEPROCESS('LEAVEAPP',3,'LEAVEPROCESS');
WF_ENGINE.setitemattrnumber('LEAVEAPP',3,'REQUESTOREMPID','100');
WF_ENGINE.setitemattrtext('LEAVEAPP',3,'REQUESTOREMPNAME','RAMA');
WF_ENGINE.setitemattrtext('LEAVEAPP',3,'LEVETYPE','EARNED');
wf_engine.setitemattrdate('LEAVEAPP',3,'LEAVEFROMDATE','10-JUN-14');
wf_engine.setitemattrdate('LEAVEAPP',3,'LEAVETODATE','11-JUN-14');
wf_engine.setitemattrtext('LEAVEAPP',3,'RMLOGINID','USER_98558');
WF_ENGINE.startprocess('LEAVEAPP',3);
COMMIT;
END;
Check the output



35 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Example 5: Provide a dropdown list to the end user
Now letus modify our previous example in such a way the Supmervisor/RM will provide
information on Leave type. If the requestor specify one type of leave, then the supervisour
may change leave type. It has to be captured in the database.
In the current scenario, the Leave types that need to be given in the notification or
1. Earned leave
2. Leave without pay
3. Other leave
That information need to be stored in the table.
Changes needed to the table
ALTER TABLE dummyEmployee ADD(rmleavetype CHAR(20));
Create a Lookup type for leave types
Internal Name :SUPLEAVETYPE
Display Name :Leave types for RM
Create Lookup codes under the above loopup
Create Lookup code 1
Internal Name :EARNEDLEAVE
Display Name :Earned Leave
Create Lookup code 2
Internal Name :LWP
Display Name :Leave without pay
Create Lookup code 3
Internal Name :OTHERLEAVE
Display Name :Other type leave
Create Item Attribute
Internal Name : LEAVETYPE
Display Name : Leave type
Type : Lookup
Lookup type : Leave types for RM
Value : Earned Leave


36 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

As this leave type has to be sent along with the message to the Supervisor/RM, drag and
drop this Item Attribute under MSGTORM
Double click on the LEAVETYPE under MSGTORM and set the following values
Source :Respond
Type :Constant
Value :Earned Leave
Modify STOREDATA procedure
CREATE OR REPLACE
PROCEDURE storedata
(
ITEMTYPE IN VARCHAR2,
ITEMKEY IN VARCHAR2,
ACTID IN NUMBER,
FUNCMODE IN VARCHAR2,
RESULTOUT OUT VARCHAR2)
IS
V_EMPID NUMBER;
V_EMPNAME VARCHAR2(20);
V_LEAVETYPE VARCHAR2(20);
V_LEAVEFROM DATE;
V_LEAVETO DATE;
V_RMUNAME VARCHAR2(20);
V_COMMENT VARCHAR2(200);
v_leavetype VARCHAR2(20);
BEGIN
V_EMPID := WF_ENGINE.getitemattrnumber(ITEMTYPE, ITEMKEY, 'REQUESTOREMPID');
V_EMPNAME := WF_ENGINE.GETITEMATTRTEXT (ITEMTYPE,ITEMKEY,'REQUESTOREMPNAME');
V_LEAVETYPE := WF_ENGINE.GETITEMATTRTEXT(ITEMTYPE,ITEMKEY, 'LEVETYPE');
V_LEAVEFROM := wf_engine.getitemattrdate(ITEMTYPE, ITEMKEY, 'LEAVEFROMDATE');
V_LEAVETO := wf_engine.getitemattrdate(ITEMTYPE, ITEMKEY, 'LEAVETODATE');
V_RMUNAME := wf_engine.getitemattrdate(ITEMTYPE, itemkey, 'RMLOGINID');
v_comment := wf_engine.getitemattrtext(ITEMTYPE, ITEMKEY, 'COMMENTS');
V_LEAVETYPE := wf_engine.getitemattrtext(ITEMTYPE, ITEMKEY, 'LEAVETYPE');

INSERT
INTO dummyemployee VALUES(V_EMPID, v_empname, v_leavetype, v_leavefrom, v_leaveto,
v_rmuname, sysdate,'A',v_comment,v_leavetype);
COMMIT;
END;
Run the workflow
BEGIN
WF_ENGINE.CREATEPROCESS('LEAVEAPP',9,'LEAVEPROCESS');
WF_ENGINE.setitemattrnumber('LEAVEAPP',9,'REQUESTOREMPID','100');
WF_ENGINE.setitemattrtext('LEAVEAPP',9,'REQUESTOREMPNAME','RAMA');
WF_ENGINE.setitemattrtext('LEAVEAPP',9,'LEVETYPE','EARNED');
wf_engine.setitemattrdate('LEAVEAPP',9,'LEAVEFROMDATE','10-JUN-14');
wf_engine.setitemattrdate('LEAVEAPP',9,'LEAVETODATE','11-JUN-14');
wf_engine.setitemattrtext('LEAVEAPP',9,'RMLOGINID','USER_98558');
WF_ENGINE.startprocess('LEAVEAPP',9);
COMMIT;
END;



37 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Example 6: Using Voting Activity



38 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s


Example 7: Events in Oracle Workflow
In this example let us know, how to use EVENTS in Oracle Workflow and then how to Raise
Event in Oracle Application and Receive event in Oracle Workflow.
Define Event in Oracle Apps
Login into Oracle apps ebiz as Sysadmin.
Goto Main Menu -> Oracle Admin Workflow -> Business Events
Click Create Event button
Name :EVENT_TEST
Display Name :EVENT GENERATED FOR A TEST
Description :This event is gerated to demonstrate the creation of a simple event
Status :Enabled
Owner Name :USER_98558 (please check with your environment)
Owner Tag :Please supply required values

Click Apply button.
Please Note that when an event is raised , information about event stoted in Data type
WF_EVENT_T.
WF_EVENT_T structure stores Event Header Properties like Event Name, Event Key ,
CoRelation ID, Parameter list etc. Once Event is created , you can raise that ,by means of
Test button.
Create the subscription for the Event

39 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

An event subscription registration indicating that a particular event is significant to a
system. When ever an event is raised , event manager searches and execute any
subscripion assocaited with Event.
Click Subscription tab. Click Create Substription button and enter the below details.
System : PRABHALA.EBS.COM (please check with your system)
Source Type : Local
Event Filter : EVENT_TEST
Phase : 20
Status :Enabled
Rule Data :Key
Action Type :Launch Workflow
On Error : Skip to next (Click next button)
Workflow type : LEAVEAPP (will chnage this after changing the reqiured workflow)
Workflow Process:LEAVEPROCESS(will chnage this after changing the reqiured workflow)
Owner name :USER_98558
Owner tag : Test subscritpion
Details of the attributes used in this subscription
Attribute Name Description
System System where you want to execute subscription. This is the system on
which we are using this Event
Event Filter The event that enables this subscription to perform an action
Phase Order in which subscription to event execute, Phase with value 1 to
99 run synchronously , 100 and above are deferred., The phase
number 0 (zero) is reserved for Oracle Workflow seeded
subscriptions
Rule Date Key or Message. Based this the action depends
Action type Four options are available for this attributes. We are using Launch
Workflow.
Workflow type The item type name of the workflow
Workflow Process Process name of the workflow that need to be called.

40 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s



Click Apply button to complete subscription creation.
As we have specified "Action Type" as "Launch Workflow", I need to create workflow with
RECEIVE EVENT activity .
Below are Steps to create Workflow with RECEIVE Event activity.
Drag the Event Activity on your workflow and Select Event Action = Receive.Since it is a
simple test i just added a wait and end activity.

41 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s


Define Required Attributes
Attribute 1:
Internal Name :EVENT_NAME
Display Name :Event name
Attribute 2:
Internal Name :Eventy key
Display Name :Event key
Attribute 3:
Internal Name :EVENT_TYPE
Display Name :Event type



42 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Raise the Event
Go to Workflow Adminstator and test the Event, by first query for your Event in Event Tab
and then Press the Test Button .
It will trigger the Event
Event In turn trigger all the subscription assocaited with the Event.
In this example, since Action Type for My Subscription is "Launch Workflow", it will trigger
my workflow as shown.
you can check the triggering of the workflow , either by query the Workflow @workflow
Admin Page > Search in Item_type/item_key
OR
by executing below database queries.
SELECT *
FROM wf_item_attribute_values
WHERE item_type='EVNTTEST';
Another query
SELECT a.item_type, a.item_type_display_name, a.activity_name
FROM wf_item_activity_status_v a
WHERE item_type='EVNTTYPE'



43 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Example 8: Sending notification to Multiple users
Some times, it may be needed to send a notification to more than one user, in that case we
can create an AdHoc role. Add the list of users to that role and send notification to that
role.
In normal case, every user created in Oracle Apps EBiz will have a role associated. They are
standard roles. AdHoc roles are created on the fly using WF_ENGINE API and used.
Now letus consider that an Employee raises a Purchase requirest and RM approves the
request. Then the request shoud go to a Finance Manager. Usually, there will be more than
one Finance manager.
So the purchase request shoud flash on any of the Finance Manager screen. On approval,
information need to be stored in the table.
Table to implement
CREATE TABLE PurchaseApproval(
requestorid NUMBER ,
requestorname CHAR(20),
purchasedetail CHAR(20),
purchaseamt NUMBER,
rmusername CHAR(20),
rmapproval CHAR,
finmanid NUMBER,
fmapproval CHAR,
fmremarks CHAR(20)
);
This system require more than one approval. At first level it should go to the Supervisor,
Then need to be approved by the Finance Manager.
So Letup create the components needed
Crate workflow using Quick Start Wizard
Item Type Details
Internal Name :FINAPROV
Display Name : Finance manager approval system
Process Details
Internal Name : FINPROCESS
Display Name : Financial Manager Process
Create required attributes
Attribute 1
Internal Name : REQUESTORID

44 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Display Name :Requestor ID
Type :Number
Attribute 2:
Internal Name : REQUESTORNAME
Display Name :Requestor Name
Type :Text
Attribute 3:
Internal Name :PURCHASEDETAIL
Display Name :Product to be purchased
Type :Text
Attribute 4:
Internal Name :PRICE
Display Name :Product Price
Type :Number
Attribute 5:
Internal Name :RMUSERNAME
Display Name :Apps user name of Supervisor/RM
Type :Number
Attribute 6:
Internal Name :FINMANROLE
Display Name :Finacial Manager role
Type :ROLE
Attribute 7:
Internal Name :FINMANID
Display Name :Finacial Manager id
Type :Number
Attribute 8:
Internal Name :FINMANREMARK
Display Name :Finacial Manager remark
Type :Text
Attribute 9
Internal Name :RMCOMMENTS
Display Name :Supervisor Comments
Type :Text

45 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s


Create 2 Messages
Message 1:
Internal Name : MSGTORM
Display Name : Message to be sent to the RM/Supervisor
Result: Display Name : RMApproval
Result: Lookup type : Approval
Message 2:
Internal Name : MSGTOFM
Display Name : Message to be sent to Financial Manager
Result: Display Name : FMApproval
Result: Lookup type : Approval
Drag and Drop the required Attributes from the Item Attribute Node into Message1 and
Message 2 nodes.
So your navigator looks as below

Define the responses from RM and FM

46 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Double click on the RMCOMMENTS attribue under MSGTORM Node
Source : Respond
Type : Constant
Double click on the FINMANID attribute under MSGTOFM Node
Source : Respond
Type : Constant
Double click on the FINMANREMARK attribute under MSGTORM Node
Source : Respond
Type : Constant
Create 2 Notifications
Notification 1:
Internal Name :NOTIFYRM
Display Name : Notification to the RM
Message : MSGTORM
Result Type : Approval
Notification 2:
Internal Name :NOTIFYFM
Display Name : Notification to the Financial manager
Message : MSGTOFM
Result Type : Approval
Drag and Drop RMUESRNAME from Item Attribute node on NOTIFYRM. Change Default
type of the newly created node under notification to Constant.
Drag and Drop FINMANROLE from Item Attribute node on NOTIFYRM. Change Default type
of the newly created node under notification to Constant.
Create procedure that Captures data in the table
CREATE OR REPLACE
PROCEDURE purchaseapprovalRM
(
itemtype IN VARCHAR2,
itemkey IN VARCHAR2,
actid IN NUMBER,
functmode IN VARCHAR2,
result_out IN OUT VARCHAR2 )
IS
v_requestorid NUMBER;
v_requestorname VARCHAR2(20);
v_purchasedetails VARCHAR2(20);
v_price NUMBER;
v_rmusername VARCHAR2(20);
V_RMCOMMENTS VARCHAR2(20);
BEGIN

47 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

v_requestorid := wf_engine.getitemattrnumber(itemtype, itemkey, 'REQUESTORID');
v_requestorname := wf_engine.getitemattrtext(itemtype, itemkey, 'REQUESTORNAME');
v_PURCHASEDETAILS := wf_engine.getitemattrtext(itemtype, itemkey,
'PURCHASEDETAILS');
v_PRICE := wf_engine.getitemattrnumber(itemtype, itemkey, 'PRICE');
v_RMUSERNAME := wf_engine.getitemattrtext(itemtype, itemkey, 'RMUSERNAME');
INSERT
INTO PurchaseApproval
(
requestorid,
requestorname,
purchasedetail,
purchaseamt,
rmusername,
rmapproval
)
VALUES
(
v_requestorid,
v_requestorname,
v_purchasedetails,
v_price,
v_rmusername,
'A'
);
END;
Create a function to store data in table on RM's Approval
When RM approves the Purchase request, we have to run a procedure that captures the
data in the table.
Internal Name : STOREDATA
Display Name : Store data in table
Function Name : purchaseapprovalRM
Function Type : PL/SQL
Create a procedure to Store FM's Approval in the table
CREATE OR REPLACE
PROCEDURE purchaseapprovalFM
(
itemtype IN VARCHAR2,
itemkey IN VARCHAR2,
actid IN NUMBER,
functmode IN VARCHAR2,
result_out IN OUT VARCHAR2 )
IS
v_requestorid NUMBER;
v_requestorname VARCHAR2(20);
v_purchasedetails VARCHAR2(20);
v_price NUMBER;
v_rmusername VARCHAR2(20);
V_FINMANID NUMBER;
V_FMREMARKS VARCHAR2(20);
BEGIN
v_requestorid := wf_engine.getitemattrnumber(itemtype, itemkey, 'REQUESTORID');
v_requestorname := wf_engine.getitemattrtext(itemtype, itemkey, 'REQUESTORNAME');
v_PURCHASEDETAILS := wf_engine.getitemattrtext(itemtype, itemkey,
'PURCHASEDETAILS');
v_PRICE := wf_engine.getitemattrnumber(itemtype, itemkey, 'PRICE');
v_RMUSERNAME := wf_engine.getitemattrtext(itemtype, itemkey, 'RMUSERNAME');
v_finmanid := wf_engine.getitemattrnumber(itemtype,itemkey,'FINMANID');
v_fmremarks := wf_engine.getitemattrtext(itemtype,itemkey,'FINMANREMARK');
UPDATE PurchaseApproval
SET FINMANID =v_finmanid,
fmapproval ='A',

48 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

fmremarks =v_fmremarks
WHERE requestorid =v_requestorid
AND requestorname =v_requestorname
AND purchasedetail=v_purchasedetails;
END;
Create a function to run the FM Approval procedure
Internal Name : STOREDATA1
Display Name : To store FM approval
Function Name : purchaseapprovalFM
Function Type :PL/SQL
Make the FINMANID compulsory for the Financial Manager
To make any specific column compulsory in the response, we need to write a validation
procedure and that need to be attached with the notification as Post Notification Function.
Also any procedure that is attached with an activity(notification/Function activity) must have a
error handling section. If an exception occurs, so that you can include context information in
the error stack to help you locate the source of an error.
The code is given below.
CREATE OR REPLACE
PROCEDURE finmanidvalidator
(
itemtype IN VARCHAR2,
itemkey IN VARCHAR2,
actid IN NUMBER,
functmode IN VARCHAR2,
result_out IN OUT VARCHAR2 )
IS
v_result VARCHAR2(20);
v_finmanid NUMBER;
BEGIN
IF(FUNCTMODE = 'RESPOND') THEN
-- TO KNOW ACCEPT OR REJECT WE CAN USE
v_result := wf_notification.getAttrText(wf_engine.context_nid,'RESULT');
-- To know Financial manager id entry is made or not
v_finmanid :=
wf_notification.getAttrText(wf_engine.context_nid,'FINMANDID');
IF (NVL(v_finmanid,0)=0) THEN
RAISE_APPLICATION_ERROR(-20002,'Finance manager id entry is mandatory');
END IF;
END IF;
EXCEPTION
WHEN OTHERS THEN
Wf_Core.CONTEXT(NULL,'FINMANIDVALIDATOR',itemtype,itemkey,actid,functmode);
RAISE;
END;
Design your workflow process
Your business process is modeled as shown in the picture below.

49 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s


Perform the following steps on the nodes in the process
Double click on NOTIFYRM.
Goto Node tab. Set the Performer
Type :Item Attribute
Value : Apps username of Supervisor/RM
Double click on the NOTIFYFM Notification
Under notification Tab
Function Name: FINMANIDVALIDATOR
Under Node tab Set Perforer
Type :Item Attribute
Value : Apps username of Supervisor/RM
Test your workflow
In this model, initially we assumed that there may be more than one finance manager and
any one can approve this.
To send notification to multiple users, we take the help of a adhoc role.
Add the Apps usernames of all those users to the AdHoc role
Send the Nofication.

50 | P a g e T e c h n i c a l L e a r n i n g S e r v i c e s

Code to perform this is given below.
DECLARE
v_adhocrole varchar2(20):='FINMEN';
v_adhocroledesc varchar2(20):= 'FINMEN';
BEGIN
--create an adhoc role and add users
WF_DIRECTORY.CREATEADHOCROLE(v_adhocrole, v_adhocroledesc);
--In this example I am using only one finman SYSADMIN. You can add any
WF_DIRECTORY.ADDUSERSTOADHOCROLE('FINMEN','SYSADMIN');
--SUPPLY OTHER VALUES
WF_ENGINE.CREATEPROCESS('FINAPROV',4,'FINPROCESS');
WF_ENGINE.setitemattrnumber('FINAPROV',4,'REQUESTORID','100');
WF_ENGINE.setitemattrtext('FINAPROV',4,'REQUESTORNAME','RAMA');
WF_ENGINE.setitemattrtext('FINAPROV',4,'PURCHASEDETAILS','LAPTOP');
wf_engine.setitemattrnumber('FINAPROV',4,'PRICE','50000');
wf_engine.setitemattrtext('FINAPROV',4,'RMUSERNAME','USER_98558');
wf_engine.setitemattrtext('FINAPROV',4,'FINMANROLE','FINMEN');
WF_ENGINE.startprocess('FINAPROV',4);
COMMIT;
END;