Sunteți pe pagina 1din 118

a) ABC of Workflow

Oracle Workflow is unique in providing a workflow solution for both internal processes and business process
coordination between applications. It automates and streamlines business processes both within and beyond our
enterprise, supporting traditional applications based workflow as well as e-business integration workflow. This
technology enables modeling, automation, and continuous improvement of business processes, routing information of
any type according to user-defined business rules. Oracle Workflow can route supporting information to each decision
maker in a business process, including people both inside and outside our enterprise.
Oracle Workflow Builder is a graphical tool that help us create, view, or modify a business process with simple drag
and drop operations. Using the Workflow Builder,we can create and modify all workflow objects, including activities,
item types, and messages etc.
Workflow Components

Depending on the Business process logic we may need to create/modify some or all of the of the following workflow process components.

Item Type

Item Type is a name/identifier of a workflow business process. Any component that we create for a workflow business
process must be associated with a particular item type.
when we save our workflow process definition is database it takes the item type as its name. Opening an item type
from databse automatically retrieves all the attributes, messages, lookups, notifications, functions and processes
associated with that item type.
Example:- Here Test Leave Workflow is name of the Leave Approval business process .
Item Attribute

Item Attribute is nothing but global variable that can be accessed/ referenced by any activity within the itemtype. An item attribute often
provides/stores information about an item that is necessary for the workflow process to complete. It also help us to share information with the
stakeholders of a business process.

There are different types of item attribute:-

a) Text:- The attribute value is a string of text


Note:- Oracle Workflow does not permit HTML content to be passed in attributes of type text. If Oracle Workflow
encounters HTML tags in a text attribute, escape characters will be applied to display the content as plain text rather
than executing the HTML.
b) Number:- The attribute value is a number
c) Date :- The attribute value is a date
d) Lookup : -The attribute value is one of the lookup code values in a specified lookup type.
e) Form :- The attribute value is an Oracle Applications internal form function.
f) URL :- The attribute value is a Universal Resource Locator (URL) to a network location. If we reference a URL
attribute in message attribute, the
notification, when viewed from the Notification Details Web page or as an HTML-formatted e-mail,
displays a link to the URL specified by the

URL attribute.
g) Document:- Document attribute is mainly used to attach document in notification and help stakeholder to see the
information. This attribute mainly
used for external document integration purpose.The following document types can be used :>> PL/SQL document
>> PL/SQL CLOB Document
>> PL/SQL BLOB Document
--- Other types of attributes will be explained later. To keep our discussion simple at this stage, the other attribute types
are skipped intentionally.
Message & Notification Activity

In our daily life, when we plan to send a letter to anybody, first we write a letter and then we put that inside an envelope, which contain
the address of the recipient.
In oracle workflow, Message can be compared with a letter and notification can be compared with envelope. In oracle workflow a message is
attached with a notification.

Recipient of the message is known as performer. Here performer needs to be added at notification level, so that workflow engine can
understand to whom the notification needs to be delivered.In performer field we need to add a value(may be dynamic by adding item
attribute),so that workflow uniquely identify the recipient from database.(Username of FND_USER table).

Each message is associated with a particular item type. This allows the message to reference the item type's attributes for token replacement
at runtime when the message is delivered. We can create a message with context-sensitive content (dynamic message body) by including
message attribute tokens in the message subject and body that reference item type attributes.

Note:- Unlike the real life envelope-letter analogy, here we can attach only a single message(letter) to a notification(envelope).
Function Activity

Function Activity is defined by Pl/SQL stored procedure or other external procedure.Our discussion in oracle workflow will be restricted to
Pl/SQL stored procedure only.Function activity helps us to embed our custom business logic applicable to workflow business process.

Example:- We need to examine whether the person has applied for a leave for more than 10 days or less than equal to
10 days.

Conclusion:The Key features of Oracle Workflow are


i)The Workflow Engine embedded in the Oracle Database implements process definitions at runtime
ii) oracle uses the Business Event System which is an application service that uses the Oracle Advanced Queuing (AQ) infrastructure to
communicate business
events between systems.
iii)The Workflow Definitions Loader is a utility program tightly integrated with the workflow builder and oracle application. This helps us to
download workflow
definition from database to flat file and upload it to database
iv)Oracle Workflow lets us include our own PL/SQL procedures or external functions as activities in our workflows. Without modifying our
application code, you can
have our own program run whenever the Workflow Engine detects that our program's prerequisites are satisfied.
v)The Notification System sends notifications to and processes responses from users in a workflow. 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 .
vi)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.
vii)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.

References:-additional 1) https://metalink.oracle.com

2) Oracle Workflow Developer's Guide ( Release 12) B31433-04


Now our goal is to create a simple custom workflow.The creation of simple workflow will be released in next tutorial.

b) Requirement Mapping & Custom Workflow Design


Now we are comfortable with ABC of workflow (refer our earlier post ABC of Workflow). As of now we know most of the workflow
components and their uses.
Lets design a simple custom workflow process and step-by-step we will make it more complex.
Basic Requirement

Our business requirement is when 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.

* => Here we are storing the information in custom table instead of absence management table of oracle apps. Here our objective just to
demonstrate how we can use function activity. Hence to keep the discussion simple and to avoid using oracle API,we are considering custom
table.
Pre-Requisite

Following are the pre-requisite to implement the solution


1) Web application which will call our custom procedure to trigger custom workflow process, is ready and accessible.
2) Oracle Workflow builder is installed and power user access is provided.
3) Access to development database is present.
Design Appraoch

Following assumption holds true for our design approach and our discussion

We are not considering the oracle provided seeded workflow processes (processes for oracle HRMS self-service functionality) and its
extensibility and availability for customization. Whether we can achieve this through oracle provided workflow processes (processes for
oracle HRMS self-service functionality) or not is out of scope of this discussion. Here our main goal is to make a discuss on how we
can create a custom workflow process.

To design a workflow processes we can consider any of the following approach


a)

Top-Down Design approach.

b)

Bottom-up approach.

We will consider the Bottom-up approach. We will first create individual workflow components and then we will use those components and
design our process.
Lets take a pen and paper and design the flow diagram.

A:User will log into the system and opens up the leave application form. Once he/she filled up with the relevant information he/she will submit the
page. Once the page gets submitted, it should call our stored pl/sql procedure with the following information
1)

The requestor person id

2)

Leave Type

3)

Leave from date

4)

Leave to date

Here the control is with the web page.


B:At this point we will take all the input values and will store it in the required item attributes.
So following item attributes needs to be defined
1)

Requestor person id

2)

Requestor User name

3)

Requestor full name

4)

Leave Type

5)

Leave from date

6)

Leave to date

Here the control is with the pl/sql procedure.Workflow will be triggered at this level.

C:Since at this point we need to send notification to supervisor, hence the performer of the notification is Supervisor.Thus we need to create
a) A notification
b) A message
c) Item attribute to store supervisor full name
d) Item attribute to store supervisor user name
e) Item attribute to store supervisor person id

Here workflow is triggered,control is with workflow engine.

D:Since we have to store the information in a table hence we have to use a function that will call our procedure to store the information in
database.

E:Supervisor can either Approve leave requisition or Reject the same. Hence the possible response could be a) Approve b) Reject.
So, we have to create a lookup type containing two lookup code a) Approve b) Reject
From the above discussion we can finalize our list of workflow components required for our workflow process
Item Attribute
1)

Requestor person id

(Type-Number)

2)

Requestor User name

(Type-Text)

3)

Requestor full name

(Type-Text)

4)

Leave Type

(Type-Text)

5)

Leave from date

(Type-Date)

6)

Leave to date

(Type-Date)

7)

Supervisor person id

(Type-Number)

8)

Supervisor User name

(Type-Text)

9)

Supervisor full name

(Type-Text)

Notification
A single notification to send information to supervisor of requestor
Message

A message needs to be created to pass the leave information to supervisor


Lookup Type/Code
A lookup type containing two lookup code a) Approve b) Reject needs to be created.
Function Activity
Each process has to have a Start activity that identifies the beginning point of the process.
An End activity should return a result that represents the completion result of the process.
Start activities are marked with a small green arrow, and End activities by a red arrow .(As shown in picture below)
Hence we have to create two function a) Start (should be marked as Start Activity)
b) End (should be marked as End Activity)
When initiating a process, the Workflow engine begins at the Start activity with no IN transitions (no arrows pointing to the activity). If more than
one Start
activity qualifies, the engine runs each possible Start activity and transitions through the process until an End result is reached.

Sample Design

Sample Design diagram shows position of different nodes (A,B,C) its position and transfer of control.
We understand from the below picture that "Web Page Leave requisition details" activity and "Pl/Sql Procedure to trigger workflow" activity
is outside the oracle workflow process.

c) Custom Workflow Development


Our Custom workflow design in pen and paper is almost finalized (Refer our previous discussion Requirement Mapping & Custom Workflow
Design ). We are also ready with the probable list of Workflow components.
Now we will proceed with the step-wise development of our custom workflow.
Design Components

To design our discussed custom workflow, we need to create following workflow components
Item Attribute
1)

Requestor person id

(Type-Number)

9)

2)

Requestor User name

(Type-Text)

3)

Requestor full name

(Type-Text)

4)

Leave Type

(Type-Text)

5)

Leave from date

(Type-Date)

6)

Leave to date

(Type-Date)

7)

Supervisor person id

(Type-Number)

8)

Supervisor User name

(Type-Text)

Supervisor full name

(Type-Text)

Lookup Type/Code
Lookup code a) Approve b) Reject
Lookup Type:- APPROVE_REJ

Function Activity

1) Start (Type:- START)


2) End (Type END)

Message
Message to Supervisor with the details of the applied leave.
Notification
notification to send message to supervisor and approve or reject the same.
Workflow Development
Now we will proceed with the stepwise development of workflow process and its components.
1) Open workflow Builder.Click on the Hammer icon to open it in Developer mode.

2) Click on the New icon, It will open up a pop-up window to create a item-type.
Internal Name:- XX_TEST
Display Name:- Test Leave Workflow
Keep the other filed as it is(with its default value-as shown in picture)

Note:- 1) We can also use the Quick start Wizard.Quick Start Wizard will help us to creates our new item type and new process activity.
2) The persistence type controls how long a status audit trail is maintained for each instance of the item type.
If we set Persistence to Permanent, the runtime status information is maintained indefinitely until you specifically purge the information

by calling the
procedure WF_PURGE.TotalPerm().
If we set an item type's Persistence to Temporary, we must also specify the number of Defining Workflow Process days of persistence
('n'). The status
audit trail for each instance of a Temporary item type is maintained for at least 'n' days of persistence after its completion date. After
the 'n' days of
persistence, we can then use any of the WF_PURGE APIs to purge the item type's runtime status information.
Here we are keeping Persistence to 'Temporary' and Number of Days to Zero(0).
3) Now to create Item Attribute, Right click on the "Attribute" and select 'New Attribute', it will open up a pop-up window which will help us to
create item attribute

Internal Name:- LEAVE_FROM_DATE


Display Name:- Leave From Date
Type:Date
Keep other field as it is

.
Define the other listed item attributes as mentioned above.
4) Now to create Item lookup Types/code, Right click on the "Item Types" and select 'New', it will open up a pop-up window which will help us to
create Lookup Type

Internal Name :- APPROVE_REJ


Display Name :- Approve or Reject
Keep the field and other tabs as it is,

Now select the newly created Lookup Type (i.e, APPROVE_REJ) and richt click on it & select 'New Lookup Code'. It will open up a pop-up
window that will help us to create new lookup code.

Internal Name:- APPROVE


Display Name:- Approve

In a similar ways create the other lookup code(REJECT).


5) To create a message Right click on the "Message" in Navigator window and click on "New Message", it will open up a pop-up window that
will help us to craete a new message.
Internal Name:- XX_TEST_APPROVER_MESSAGE
Display Name:- test Leave Approver Message
Priority
:- Normal

Select the Subject Line and the body of the message. Body of the message can be in 'Plain Text Mode' or in HTML mode.
Subject Line:-Leave Approval for person &REQUESTER_EMP_NAME(&REQUESTER_EMP_NO)
Body:- A sample body is given below.
Dear <b>&SUP_EMP_NAME</b>,
The person &REQUESTER_EMP_NAME(&REQUESTER_EMP_NO) has submitted leave requisition. Request you please take necessary
action on the requisition.
<br></br>
<u>Leave Details</u>
<table>
<tr><td>Leave Type</td><td>Start Date</td><td>End Date</td></tr>
<tr>td>&LEAVE_TYPE</td><td>&LEAVE_FROM_DATE</td><td>&LEAVE_TO_DATE</td></tr>
</table>
<br></br>
Regards
HR Team

Here we have used Token substitute an attribute.The method of doing this &<Internal name of Attribute>. In runtime Workflow replaces
those(As mentioned in bold) with the corresponding attribute value.

Note:- To Token substitute an attribute, we have to make those attribute as message attribute. To make a attribute available in
message copy the respective item-attribute and paste it in message. All the message attribute will appear under the respective
message.
Keep the source as 'Send'. It means we are sending the value of the attribute to the performer of the notification(to which th message is
attached).
If the source is 'Respond', it means we want the value from the responder(will be discussed in detail later).

In our example Supervisor either can approve the leave requisition or Reject the same. Hence we have provide the supervisor two result button
(APPROVE ; REJECT). To create the button click on the result tab(as shown in the picture) above and the add the desired lookup type.
Workflow will automatically place the buttons in run time.
Provide the following details
Display Name:- Approve/Reject
Lookup Type:- Approve Or Reject

6) To create notification right click on the "Notifications" and select "New Notifications". It will open a pop-up window that will help us to create a
Notification
Internal Name:- XX_TEST_LEAVE_NOTIF
Display Name:- Test Leave Notification
Message:- Attach the newly created message.
Result Type:- Since our notification will go to Supervisor and he/she can approve/reject leave requisition.Thus we need to have two different
transition from the notification. Because of this we need to attach our newly created Lookup type.

Keep the other tabs as it is,

Note:- 1) Check Expand Roles to send an individual copy of the notification message to each user in the role. The notification remains in a
user's notification queue
until the user responds to or closes the notification.
one should expand roles to send out a broadcast-type/FYI type(message that don't require any response from performer) message for
which he/she wants
all users of that role to see.Otherwise if one user from the roles closes the notification, it will be closed from all the other users.
2) Here we don't have any option to attach performer with the notification. It will be available once we use the notification in the
process.
7) To create a Function activity, right click on "Function" and select "New Function". It will opens up a pop-up window which will help us to
create function.
Internal Name:- START
Display Name:- Start
Function Name:- WF_STANDARD.NOOP**
Function Type:- PL/SQL
Result Type:- <None>(keep default value as it is)

Cost

:- 0.00( Keep default value as it is)

** => WF_STANDARD.NOOP is oracle provided Seeded package.procedure mainlly used as Pl/Sql procedure for Start and End activity.

Note:- Here we don't have any option to mark the function as 'START' or 'END'. This can be done once we use the same in a process.
8) Now to create Workflow process right click on "Processes" in Navigation Tree and select "New Process". It will pop-up a window which will
help us to define process.
Internal Name:-XX_TEST_PROC
Display Name:- Test Leave Approval Process
Result Type:- <None>(Keep the default value as it is)
Runnable:- Checked.

Note:- Check Runnable so that the process that this activity represents can be initiated as a top-level process and run independently.
If process activity represents a subprocess that should only be executed if it is called from a higher level process,then uncheck
Runnable.
9) Till the point 8 we have discussed, how we can define each workflow components. Now we have bind them together to create a workflow
process.
a) Double click on the newly created icon, it will open up a process window.Resize the window so that both the window(Navigator, process
window) as shown in
the figure below.

b) First "Drag & Drop" START & END Function activity to Process window. Once it is appear in process window, double click on the icon, it
will open up the
Function activity window. Go to "Node" tab and select 'Start' for START activity in 'Start/End' field.(As shown in picture below.)
Do the same for END Activity.(Select 'End' in 'Start/End' field.)

Note:-Start and End activity can be distinguished by the following identification mark
Start activities are marked with a small green arrow
End activities by a red arrow.

c) Now drag the notification from Navigator window to process window and double click on the notification icon. A notification properties
details
window will open up.
As mentioned, we need to add performer in the notification .
Go to "Node" tab of the property window. Go to the Performer Section.
Type :- "Item Attribute" &
Value:-"Supervisor User Name".

d) Now we need to make transition between different activity. To create transition between source and destination hold down right mouse
button and drag your
mouse from a source activity to destination activity.
Note:- 1) If the source activity has no result code associated with it, then by default, no label appears on the transition.
2) If the source activity has a result code associated with it, then a list of lookup values appears when you attempt to create a
transition to the
destination activity. Select a value to assign to the transition. You can also select the values <Default>, <Any>, or <Timeout> to
define a
transition to take if the activity returns a result that does not match the result of any other transition, if the activity returns any
result, or if the
activity times out, respectively.

Saving Workflow Definition


1) Our workflow is ready to save it in database. Before saving it to database we must validate the definition.

2) Once the definition is validated, go to File >> Save. It will open up a pop-up window with the save option (database or Local). Select the
database option and provide the database credentials to save.

Our Custom Workflow is now ready to be triggered. The triggering mechanism will be discussed in next topic.

References:- 1) Oracle Workflow Developer's Guide


Release 12
Part No. B31433-04

d) Triggering a custom workflow


We are ready with our custom workflow definition and saved in database(Ref:- Custom Workflow Development ).Now we have to
prepare pl/sql procedure that will trigger our custom workflow.Our custom workflow will be triggered when it(pl/Sql procedure) will be called by

any other processes(viz. from a web page or from any other pl/sql procedure etc).
The input parameter of this process must be as mentioned below.
1) Person Id :- person id of the person who has submitted the request
2) Leave Type:- Type of leave person has applied
3) Leave From Date:- Start date of leave
4) Leave to Date:- End date of leave
We are taking input to ensures that we received all the information that user entered in web page application and required for workflow
process.
Item Key

When a workflow is triggered,It creates a instance of the workflow definition. To identify the instance of the workflow a string is required.
The string that uniquely identifies the instance of the workflow definition is known as item-key. Item-key can be alpha-numeric.
Note:- Different item-type can have same item-key but for same item-type it is unique. Analogy can be drawn with concurrent program internal
name and request id.
Development of Custom Procedure

The following tasks needs to be performed to trigger a custom workflow successfully


1) Create the process
2) Set attribute values
3) Start the process
4) commit transaction
1) Create the process
Oracle provided us API to create the instance of the workflow definition process.
wf_engine.createprocess(itemtype => <Internal name of item type>,
itemkey => <Item key value>,
process => <Internal name of process>
);
Here v_process should be internal name of runnable process.Here it is XX_TEST_PROC.

2)Set attribute values


Once the process is created, it actually creates the instance of the workflow definition. Once the instance is created, we need to
set attribute values. To set the attribute values we need to call oracle provided workflow apis
wf_engine.SetItemAttrText(itemtype => <Internal name of item type>,
itemkey => <Item key value>,

aname =><Internal name of attribute>,


avalue =><Attribute value that need to set>);
wf_engine.SetItemAttrDate(itemtype => <Internal name of item type>,
itemkey => <Item key value>,
aname =><Internal name of attribute>,
avalue =><Attribute value that need to set>);
wf_engine.SetItemAttrnumber(itemtype => <Internal name of item type>,
itemkey => <Item key value>,
aname =><Internal name of attribute>,
avalue =><Attribute value that need to set>);

3)Start the process


wf_engine.startprocess(<Internal name of item type>type, <Item key value>);
4) Commit Transactions
commit;

Triggering Workflow from a pl/Sql block

Instead of trigerring workflow from a Web-page just for sake of illustration we will trigger workflow from a pl/sql block by passing
necessary parameter values to our TRIGGER_WORKFLOW procedure.

DECLARE
BEGIN
XX_TEST_LEAVE_PKG.TRIGGER_WORKFLOW(P_PERSON_ID
=> 14760
,P_LEAVE_TYPE
=> 'Seek Leave'
,P_LEAVE_FROM_DATE => '01-MAR-2011'
,P_TO_DATE
=> '04-MAR-2011'
);
END;

Once the above block is exceuted it will trigger the custom workflow and notification will go to the approver for approval.
Please see the screen shot below

To track the present status of the workflow follow the below mentioned navigation.
Login as (Sysadmin) >> Workflow Administrator Web Applications >> Status Monitor>>

Enter the internal name of item type of your workflow under "Type Internal Name" and click on "GO". You will find the list of
workflows that was triggered. Select any of them and click on View Diagram.

e) How To Take Approver's Input


a) How To Take Approver's Input- Providing a Free Text
field
We have already build a simple custom workflow. Now we will make our previous workflow more n more
complex.
Basic Requirement

Our initial requirement was "when a person applies for a leave, it should go his/her supervisor for approval and once it is approved save
the information in database . If the leave gets rejected, dont store any information in database."
Now we will change our requirement a bit. It is as mentioned below
"when a person applies for a leave it should go his/her supervisor for approval. Approver must be able to provide his/her comments for
approval or rejection of the requisition(currently keep it as optional).Once it is approved save the information in database . If the leave
gets rejected, dont store any information in database."

(Change requirement is in bold)


Design Appraoch

To implement the above requirement, we have to perform the following steps to update the existing workflow definition.
1) Create a text type item-attribute
Internal Name:- SUPERVISOR_COMMENT
Display Name:- Supervisor Comment
Type
:- Text
2) Copy the item attribute and paste it under message( Creating a message attribute). Open the message attribute and Select Source as
"Respond"

3) Click on Apply and OK.

4) Validate the definition and save it in database.


5) Now our workflow is ready to trigger.Once we trigger our workflow, the approver notification will looks like as shown below.(wft file is
uploaded)

b) How To Take Approver's Input- Providing a Drop Down


field
Now we know how to put a place holder for approver comments.Now we will learn how we can provide a list of
values, so that approver can select a possible values from the drop down.
Basic Requirement

Our old requirement looks like "when a person applies for a leave, it should go his/her supervisor for approval. Approver must be able to
provide his/her comments for approval or rejection of the requisition(comments is optional).and once it is approved save the information in
database . If the leave gets rejected, dont store any information in database."
Now we will change our requirement a bit. It is as mentioned below
"when a person applies for a leave it should go his/her supervisor for approval. Approver must be able to provide his/her comments for
approval or rejection of the requisition(comments optional). Approver must also be able to select the Organization Leave Type from a list
of values . If the leave gets rejected, dont store any information in database."
The possible "Organization Leave Type" list of values are
1) Medical Leave
2) Personal Unpaid Leave
3) Personal Paid Leave
(Change requirement is in bold)
Design Appraoch

To implement the above requirement, we have to perform the following steps to update the existing workflow definition
1) As we know Lookup-type/lookup-code provides us the static list of values. Hence first we have to create a lookup type that will hold all the
"Organization Leave Type" as lookup code.
a) Create a lookup type
Internal Name:- APPROVER_LEAVE_TYPE
Display Name:- Approver Leave Type

b) Create lookup code as mentioned below


1) Medical Leave
Internal Name:- MEDICAL_LEAVE
Display Name:- Medical Leave
2) Personal Unpaid Leave
Internal Name:- PERSONAL_UNPAID_LEAVE
Display Name:- Personal Unpaid Leave
3) Medical Leave
Internal Name:- PESONAL_PAID_LEAVE
Display Name:- Personal Paid Leave
4) Create another lookup code
Internal Name:- NULL
Display Name:- -----Null----( The reason of this 4th lookup code will be discussed later on**)

2) Now our lookup type and lookup code is created. We have create a item-attribute of type lookup and we will attach this lookup to the item
attribute.

3) Since we need to make this attribute available to approver, so we have make it also a message attribute. we will also take the input from
approver. Thus this item attribute must be a message attribute with Source as "Respond"
Copy the item attribute and paste it in the message. Open the attribute and make the Source as "Respond". Also ensure that we have
Default value Type "Constant" and Value is "----Null----".

4) Our Design is ready to test. Validate the design and save it to database.
5) Now trigger the workflow and Check the notification with approver.

** Note:1) We have created additional lookup code as 'NULL' (Remember here NULL is also a value) and make it a default value of the item
attribute and message
attribute as well.
If don't select any default value and keep it as blank (No value). Then in application approver will see no default value in the field. Since
our field is not a mandatory field, and hence supervisor can left the field as it is and try to approve or reject the requisition. If the field remains

blank, then supervisor will receive an application error. Hence we have created a additional lookup code "-----Null-----"

2) Since lookup code NULL doesn't corresponds to database NULL (Blank), Hence it is responsibility of the developer to decode it and re-set
the value to NULL(Blank).

c) How To Take Approver's Input- Making approver


comments a mandatory Free Text field
We have already discussed how we can provide a free text field to approver. Now Our aim is to make the field mandatory.
Basic Requirement

Our old requirement looks like "when a person applies for a leave it should go his/her supervisor for approval. Approver must be able to
provide his/her comments for approval or rejection of the requisition(comments optional). Approver must also be able to select the Organization
Leave Type from a list of values . If the leave gets rejected, dont store any information in database."

Now our changed requirement will looks like


"when a person applies for a leave it should go his/her supervisor for approval.Approver must be able to provide his/her approval/rejection
comments. The comments must be entered by the approver while rejecting the leave requisition.If he/she rejects the leave requisition
without entering comments, then it should raise an application error.If he/she approves the requisition it should be optional.Approver
must also be able to select the Organization Leave Type from a list of values . If the leave gets rejected, dont store any information in
database."

Design Appraoch

Following interpretation can be drawn from the above requirement.


1) The comment field is mandatory while rejecting the leave request.
2) The comment field is remain as optional if he/she approves the requisition.

From the above derivation, we are clear that when approver entered his/her response(on button click), we have to check whether
he has entered some value in the text box or not.
To implement the above business case we have to learn "Post Notification Function"( commonly known as PNF).
PNF is nothing but a pl/sql procedure that will be called on button click. The procedure is attached with the notification.
Let us first create a procedure then we will attach the same with the notification.
1) Any procedure that is attached with an activity(notification/Function activity) must have following input parameter.We need not to bother

about how the parameter values will be passed, the workflow engine takes the responsibility to pass the parameter value when it is called.

ITEMTYPE
IN
VARCHAR2
ITEMKEY
IN
VARCHAR2,
ACTID
IN
NUMBER,
FUNCTMODE IN
VARCHAR2,
RESULT_OUT IN OUT VARCHAR2

2) 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
Wf_Core.CONTEXT(<Package Name>,
<procedure name>,
itemtype,
itemkey,
actid,
functmode);
RAISE;

3) We are almost ready with the format of pl/sql procedure that will be called by workflow process. Now we will build our logic step by step
a) First we have to read which button the performer has pressed. This can be identified by the following API
l_notfication_result := wf_notification.getAttrText(wf_engine.context_nid,
'RESULT');
The API will return the internal name of the lookup code corresponding to button.(as we know buttons are created with the lookup
code attached with
message)
b) Now we have to find what is the comment approver has entered.
l_sup_comments:=wf_notification.GetAttrText(nid => wf_engine.context_nid,
aname => 'SUPEVISOR_COMMENT'
);
Here l_notfication_result and l_sup_comments are local variable.

c) Set all the inputs that we have taken from supervisor to corresponding attribute. This is to ensure that in future we

can reference or share this value.(Say once it is approved we can share the approver comments and org leave type he/she has
selected with employee).

d) Now if the l_notfication_result is 'REJECT' and l_sup_comments is null then we have to raise application error with proper
error message.
if l_notfication_result is 'REJECT' and l_sup_comments is not null then we have to set the RESULT_OUT parameter.

While setting the Result_out parameter we must follow the format


RESULT_OUT :='COMPLETE:<Internal name of result>;
e) If the l_notfication_result is 'APPROVE' then set the result_out

4) Our procedure is ready to attach with the workflow. Open the approver notification and attach the procedure in "Function Name"

field.

5) validate the design and save it in database.

Now our workflow is ready to test.

6) If the approver clicks on 'Reject' button without entering any comments, it will through an error(as soon below)

Note:- In our workflow we have not created any function that will store the data in custom table once it is approved. It is kept for
reader.
Hint:- The functmode in that case will be 'RUN'.

d) How To Take Approver's Input- Launching Oracle


Form from Workflow(from Approver's Notification)
Oracle Workflow also provide us a provision to launch Oracle form/s from a notification.It helps the performer to see the details
that is stored in core HR without explicitly login into system from another session.
We are now quite familiar with oracle workflow and already developed some of simple workflows. Now we will discuss here how can we give
the user a provision to open a form from notification itself.
Basic Requirement

Our old requirement looks like "when a person applies for a leave it should go his/her supervisor for approval.Approver must be able to
provide his/her approval/rejection comments. The comments must be entered by the approver while rejecting the leave requisition.If he/she
rejects the leave requisition without entering comments, then it should raise an application error.If he/she approves the requisition it should be
optional.Approver must also be able to select the Organization Leave Type from a list of values . If the leave gets rejected, dont store any
information in database."

In addition to the above requirement:- The approver should able to view/edit the person "Special Information Types" before
approving the leave request.
Design Appraoch
To implement the above requirement, we have to create a "Form Type" item attribute
1) Create a new item attribute of 'Form' type
Internal Name:- PERSON_SPECIAL_INFORMATION
Display Name:- Person Special Information
Type:Form
Default Type:- Constant
Value:PERWSPDC
The format of the default value should be:- <Function Name>:argument1="value1" ......
Function Name:- The internal name of the form function that open up the Special information while clicking on the form menu

argument1:- arguments required for form


Value1:- value for argument1.The value of argument can be a text string enclosed in quotes (" ") or can be token substituted with another item
type attribute in where &item_attr represents the internal name of the item type attribute
<Function Name>:argument1="&item_attr".......

Example:- If we want to make special information type form as read only then it should be
PERWSPDC:QUERY_ONLY="YES"

2) Now copy this item attribute and paste it in message to make it a message attribute.Keep the message attribute source as
Send.
3) Save the definition in database. Once we trigger the workflow notification will looks like as shown below

Note:- Once we click on the hyper link available in the notification it will open up the forms that shows the list of valid responsibility
attached with the person. The person needs to select the proper responsibility to open up the desired form otherwise it will throw

an error.

Once we select the desired responsibility the SIT form will open up and if we query for a person, it will open up the details in
editable mode.

Note:1) As we discussed earlier,form will open list of valid responsibility present with the user. If we select wrong responsibility that
doesn't contain SIT form, then it will through an error.

2) If we want to open up our form in "view only" mode then we have to define the default value as mentioned below
PERWSPDC:QUERY_ONLY="YES"
(format:- <Function Name>:argument1="Value1".......)
Here Function Name:- PERWSPDC
Argument1
:- QUERY_ONLY
Value1
:- YES
3) By default, when a user chooses an attached form link in a notification, Oracle Applications displays a list of responsibilities
assigned to that user . The user can then select the responsibility with which he or she wants to navigate to the form.we can
optionally specify the responsibility through which we want users to access that form. In this case, users do not need to select a
responsibility when they choose the attached form link; instead, they can navigate directly to the form. However, we must ensure
that the users who receive the notification have the specified responsibility assigned to them.

To specify a responsibility in the form attribute, append two special arguments in the argument string for the form function.
#RESP_KEY - The responsibility key
#APP_SHORT_NAME - The application short name for the responsibility
The value for each of these arguments can be a text string enclosed in quotes (" ") or can be token substituted with another item
type attribute.

Now save the definition and trigger the custom workflow. The notification will contain a link that will open a form in View mode
from a specific responsibility (here it is US HRMS SUPER Manager).

4) It is very obvious that different person will have different responsibility depending on their role in organization.So, It is very
much required to make the #RESP_KEY and #APP_SHORT_NAME argument value dynamic.
The default value should be
PERWSPDC: QUERY_ONLY="&QUERY_ONLY" #RESP_KEY="&RESP_KEY" #APP_SHORT_NAME="&RESP_APL"
(Format:- Function_Name:Argumnt1="&<Internal name of item attribute>"..................)
Here QUERY_ONLY,RESP_KEY,RESP_APL are three newly created item attribute.

Remember:- Copy all the item attribute and paste it in message to make a message attribute along with the form attribute

Since we have used three attribute in the default value of Form attribute, so we need to set the value for those attribute. We can
set it while triggering workflow.

Note:-'Send' and 'Respond' message attributes of type Form appear only when your Worklist Web pages are
launched from Oracle Applications. The attached form icon is enabled if a notification message includes
a 'Send' message attribute of type Form. The notification recipient can click on the attached form icon to
drill down to the form function defined by the message attribute.
Hence Form attribute can only appear when notification is accessed through web page not from Email.

References
1) https://metalink.oracle.com
2)Oracle Workflow Developer's Guide ( Release 12) B31433-04

f) How To Attach Document With Notification


Oracle Workflow also provide us a provision to attach document and help us to share information with the different stakeholders
of business process (whereever is required) .
In a workflow process, we can attach documents generated by a PL/SQL procedure, which we call PL/SQL, PL/SQL CLOB, or
PL/SQL BLOB documents.
Here we will discuss about the ways to attach PL/SQL BLOB and PL/SQL CLOB with the notification.
Basic Requirement

Our old requirement looks like "when a person applies for a leave it should go his/her supervisor for approval.Approver must be able to
provide his/her approval/rejection comments. The comments must be entered by the approver while rejecting the leave requisition.If he/she
rejects the leave requisition without entering comments, then it should raise an application error.If he/she approves the requisition it should be
optional.Approver must also be able to select theOrganization Leave Type from a list of values . If the leave gets rejected, dont store any
information in database.The approver should able to view/edit the person "Special Information Types" before approving the leave request."
In addition to the above requirement:- When a Person applies for leave* he/she also submits the medical document. Approver should
able to see the submitted medical document submitted by person.
* ==> Here we are considering only sick leave.
Assumption

Following are the assumptions based on which our design will be build
1) Here Workflow design always consider that leave type is "sick leave".

2) User submitted document is available at server side(not in oracle table).


3) Application always check that when a person submits Sick Type leave, he/she also submitted the medical document
4) Submitted medical document is available at server side "/usr/tmp" location

Solution Approach

Here we will mainly discuss about the PL/SQL BLOB document attribute and its usages.We also explain how we can modify the
code for PL/SQL CLOB document attribute.

1) Workflow Part
a) First we have to create a attribute of type text.
Internal Name:- BLOB_DOC_ID
Display Name:- Document Id for Blob
Type

:- Text

This attribute will store the document id for Blob document.This will help workflow(also developer) to uniquely identify the
document available in database

b) Now create a document** type item attribute


Internal Name:- LEAVE_BLOB_DOC
Display Name:- Leave document of Type Blob
Type

:- Document

Default Value:-plsqlblob:XX_TEST_LEAVE_PKG.GETBLOBDOC/&BLOB_DOC_ID
** ==>The "Frame Target" field is not applicable for attributes of type document. For document attributes, this field is
reserved for future use.
***==> If we want to pass a static value for document identifier(document id) then the format will be look like

plsqlblob:<package>.<procedure_name>/XXXXX . Here XXXX is a string value.


Example:- plsqlblob:XX_TEST_LEAVE_PKG.GETBLOBDOC/123
plsqlblob:XX_TEST_LEAVE_PKG.GETBLOBDOC/ABC_123

For CLOB document the format will be


For static:-

plsqlclob:<package>.<procedure_name>/XXXXX

For dynamic:- plsqlclob:<package>.<procedure_name>/&<Internal name of Document id attribute>

c) Now copy the both the attribute and paste it in message(make it a message attribute).Open the "LEAVE_BLOB_DOC"
message attribute (attribute under message) and click on the "Attach Content". This will display the document as icon in the
notification

d) Save the workflow definition to database.

2) Pl/Sql Part
We have already save our workflow definition to database. Now we have to create pl/sql procedure that will generate the Blob
document.
The format of the PL/SQL procedure must be as mentioned below.We need not to bother about the input parameter. Oracle

Workflow Engine will take care of that.


PROCEDURE <procedure_Name> (document_id IN VARCHAR2,
content_type IN VARCHAR2,
document

IN OUT NOCOPY BLOB,

document_type IN OUT NOCOPY VARCHAR2


) is
<Declare local Variable>
Begin
<Executable logic>;
---------------------------Exception
When Others then
wf_core.CONTEXT('<Package Name>',
'<Procedure Name>',
document_id,
content_type
);
RAISE;
End
<procedure_Name>;

a) First we have to set the value item attribute "BLOB_DOC_ID" for document identifier.This can be done within triggering
workflow procedure where we are setting other attribute values.The value can be anything depending on the business
requirement and design.We can define our own pl/sql logic to identify the desired value.
Example:- Since we are reading file from server hence we can set the value as <name of the medical document>_<itemkey>.
For simplicity we have use item key as document id.

b) Now we create a new procedure with the name same as that is given in default value of document attribute.(Remember the
procedure will be under the same package as we have mentioned in default value
1) create a oracle directory pointing to the directory where our file exists.

2) Define BFILE locator of the location where actually file is located.(bfilename utility is explained in 5) iRecruitment Data
Migration - How To Migrate Resume topic)

3) Create a temporary BLOB or CLOB and its corresponding index in your default temporary tablespace
using dbms_lob.createtemporary utility. This will help us
to manipulate the temporary LOBs with PL/SQL.

DBMS_LOB.CREATETEMPORARY (lob_loc IN OUT NOCOPY BLOB,


cache IN
dur

IN

BOOLEAN,
PLS_INTEGER := 10);

lob_loc:- LOB Locator


cache :- Specifies if LOB should be read into buffer cache or not.
dur :- Specifies whether the temporary LOB is cleaned up at the end of the session or call. If dur is omitted, then the
session duration is used.
Note:-This function can be used for CLOB also.
4) Open the file in read-only mode.

5) Now load the Blob into a local variable from file using utility DBMS_LOB.LOADBLOBFROMFILE.
DBMS_LOB.LOADBLOBFROMFILE (dest_lob => l_temp_blob,
src_bfile=>l_file_on_os,
amount=>dbms_lob.getlength(l_file_on_os)
,dest_offset=>l_dest_offset --in out parameter
,src_offset =>l_src_offset);
This will store the data from BFILE to internal BLOB.
dest_lob :- BLOB locator of the target for the load.

src_bfile :- BFILE locator of the source for the load.


amount :- Number of bytes to load from the BFILE.
dest_offset:- Offset in bytes in the destination BLOB (origin: 1) for the start of the write.
src_offset :- Offset in bytes in the source BFILE (origin: 1) for the start of the read
6) Now close the file.
7) Again create a temporary BLOB so that we can copy our recently created BLOB data from local variable to our output
variable "document"
8) Copy the BLOB stored in local variable to document output parameter using dbms_lob.Copy utility
DBMS_LOB.COPY (dest_lob

IN OUT NOCOPY BLOB,

src_lob

IN

BLOB,

amount

IN

INTEGER,

dest_offset IN

INTEGER := 1,

src_offset IN

INTEGER := 1);

dest_lob

:- Locator for the destination LOB

src_lob

:- Locator for the source LOB

amount

:- Number of bytes (BLOB) or characters (CLOB, NCLOB) to copy

dest_offset :- Location of the byte (BLOB) or character (CLOB, NCLOB) in the destination LOB at which the copy operation
begins. Note default value of 1
src_offset :- Location of the byte (BLOB) or character (CLOB, NCLOB) in the source LOB at which the copy operation begins.
Note default value of 1
Note:-This function can be used for CLOB also

9) Now we have to set the "document_type" parameter. We have to set the value in the following format

document_type := '<MIME TYPE>; name=<document name>';

MIME TYPE: can be determined from the extension of the document. The details of MIME type is discussed in 5) iRecruitment
Data Migration - How To Migrate Resume topic

Here for shake of simplicity we have hard coded the value.

10) Compile the code and ready for triggering the worklfow.

NOTE:- 1) For CLOB Document most of the part is same, only we have to use DBMS_LOB.LOADCLOBFROMFILE utility
to load the data from BFILE.
DBMS_LOB.LOADCLOBFROMFILE (dest_lob
IN OUT NOCOPY BLOB,
src_bfile
IN
BFILE,
amount
IN
INTEGER,
dest_offset IN OUT
INTEGER,
src_offset IN OUT
INTEGER,
bfile_csid
IN
NUMBER,
lang_context IN OUT
INTEGER,
warning
OUT
INTEGER);
dest_lob
:CLOB/NCLOB locator of the target for the load.
src_bfile
:BFILE locator of the source for the load.
src_offset :Offset in bytes in the source BFILE (origin: 1) for the start of the read.
bfile_csid :Character set id of the source (BFILE) file
warning
:- Indicates something unexpected happening during load.

lang_context :Language context, such as shift status, for the current load.
dest_offset :Offset in characters in the destination CLOB (origin: 1) for the start of the write.
amount
:Number of bytes to load from the BFILE.
2) Instead of storing it in local variable then to output parameter, we can directly store it is output parameter.
Just for the shake of understanding of dbms_lob.Copy utility we stored it in local variable.
3) For PL/SQL and PL/SQL CLOB documents that contain text or HTML, the document generated by
the PL/SQL procedure
can e
ither be displayed within the text of a notification or included as an
attachment.
Other types of content in PL/SQL CLOB documents, as
well as all PL/SQL BLOB documents, can only be included as

attachments.
4) If no document type is supplied, then text/plain is assumed.
5) if we don't make document id attribute(here for BLOB it is "BLOB_DOC_ID" and for CLOB it is "LEAVE_CLOB_DOC_ID" ) as
message attribute,
we will face an error while clicking on the attachment icon

References:-

1) https://metalink.oracle.com
2) Oracle Workflow Developer's Guide ( Release 12) B31433-04

Disclaimer:- This is a knowledge sharing site. This topic talks about a custom solution. Oracle may not provide you a support for any
data
corruption or any other problem in your custom code/problem arises because of the custom code. The author is not
responsible for any
kind of system/data problem appears because of usages of this code.Reader/implementer must do it on his/her own
risk/responsibility.

g) How To Send Notification To Multiple Users


Oracle Workflow roles are stored in the database, in the Oracle Workflow directory service.The performer can be an
item type attribute that dynamically returns a role.To send a single notification(FYI/Actionable) to multiple users we
have to use Role attribute as performer of that notification. The attribute value must be the internal name of a role.
Here we will discuss how can we send a single notification to multiple users.
Basic Requirement

Our old requirement looks like "when a person applies for a leave it should go his/her supervisor for approval.Approver must be able to
provide his/her approval/rejection comments. The comments must be entered by the approver while rejecting the leave requisition.If he/she
rejects the leave requisition without entering comments, then it should raise an application error.If he/she approves the requisition it should be
optional.Approver must also be able to select theOrganization Leave Type from a list of values . If the leave gets rejected, dont store any
information in database.The approver should able to view/edit the person "Special Information Types" before approving the leave
request.Before approving the sick leave request the approver must able to see the submitted medical document."
Now we will twist our original requirement- Instead of going to Supervisor for approval, all the leave request must go to the following
identified people

ROLE1_APPR (User name of the person)

ROLE2_APPR (User name of the person)

ROLE3_APPR (User name of the person)

Solution Approach

First we will discuss about the changes that we need to do in workflow Definition.
A) Workflow Part
1) Load the latest workflow definition from database.
2) Create an item attribute of Type Role
Internal Name:- XX_TEST_ROLE
Display Name:- Test Role for Approval
Type
:- Role

3) Now we have to add this newly created role to the performer of the notification (Initially it was Supervisor User
Name). Now open the process (in our case it will be "Test Leave Approval Process"). Open the notification and go to
the "Node" tab. Modify the performer.

4) Validate your design and save it to database.


B) Role Definition create Part
Role can be defined and used in worklfow in two different ways.
a) Create a Global Application Role

b) Create database Adhoc Role


We will first discuss how can we define Role from Oracle Application and use the same in workflow.
a) Create a Global Application Role and its usages in workflow
i) Go to UK HRMS Manage >> Transaction Maintanance >> Global Roles
ii) Create your custom Global Role and add the desired users (Users must have a valid active fnd_user entry). Save
your definition.

iii) Our Application Role definition creation is complete now we have to set the value for our newly created Role
attribute. The value of the Role attribute should be the
name of the role. Workflow engine will take the names from the role and will send the notification automatically.
We will set the value for Role attribute in our Trigger workflow procedure (Where we are setting the other attribute

values)
To set the Role attribute we need to call wf_engine.SetItemAttrText procedure. This will internally check for Role
attribute(though this utility is for setting Text attribute) and perform the task accordingly.

iv) Now compile the package and workflow is ready to trigger.

b) Create database Adhoc Role and usages


Instead of creating a Global Role from application we can also create an database adhoc role and use the same to
send notification.
i) Create a adhoc Role using wf_directory.CreateAdHocRole ultility. This will create a role in database,.
wf_directory.CreateAdHocRole(role_name
in out varchar2,
role_display_name
in out varchar2
language
in varchar2 default null,
territory
in varchar2 default null,
role_description
in varchar2 default null,
notification_preference in varchar2 default MAILHTML,
role_users in varchar2 default null,
email_address
in varchar2 default null,
fax in varchar2
default null,
status in varchar2
default ACTIVE,
expiration_date in
date default null,
parent_orig_system
in varchar2 default null,
parent_orig_system_id in number default null,
owner_tag
in varchar2 default null
);
Enter the value for "role_name" (Must not be more than 320 character and keep the name in uppercase) and
"role_display_name" parameter. Keep the other parameter to its default value.
If you want to make this role inactive after definite time period enter value for it (Ex:- for 365 days it should be
sysdate+365. Means after 365 days role will be expired).
Here
role_name
=>XX_TEST_ADHOC_ROLE
role_display_name=>Test Adhoc Role
ii) Add the user to the newly created Role using wf_directory.AddUsersToAdHocRole utility.
wf_directory.AddUsersToAdHocRole(role_name in varchar2,
c in varchar2
)

Here
role_name => Internal name of the role
role_name => User name of the list of users that we need to add. The user name of the users must be either
comma/space separated.
iii) Now set the Role attribute value. The value of the Role attribute should be the Internal name of the adhoc role.
To set the Role attribute we need to call wf_engine.SetItemAttrText procedure. This will internally check for Role
attribute(though this utility is for setting Text attribute) and perform the task accordingly.

iv) Now compile procedure and workflow is ready to trigger.


Note:- 1) As we see we can define Role in two ways 1) Global Application Role 2) Database Adhoc Role.

When we have a identified static list of approver/stakeholder to whom we need to send the notification
we will use the Global Application
Role. It is easy to maintain.
When we have a dynamic list of approver/stakeholder (if our requirement is something like send the
notification to all the people who are in a
particular grade) to whom we need to send the notification we will use the database adhoc Role.
2) If we check the "Expand Roles"(Double click on notification >> Notification Tab) check box it will send an
individual copy of the notification message to each user in the role(The notification id will be different). The
notification remains in a users notification queue until the user responds or closes the notification.
Since this is a actionable notification and we are not using voting activity thus "First responder Win" happen.
If any of the role performer acts on the notification it will "Closed" in his/her queue. Whereas other will see it
as "Cancelled".

3) Oracle Workflow does not support including the action history in a notification with the Expand Roles check
box selected, which causes a separate copy of the notification to be sent to each user in the recipient role.

References:-

1) https://metalink.oracle.com
2) Oracle Workflow Developer's Guide ( Release 12) B31433-04
3) Oracle. Workflow API Reference Release 2.6.3.5 Part No. B1216302

Disclaimer:- This is a knowledge sharing site. This topic talks about a custom solution. Oracle Corporation may not provide you a
support for any data corruption or any other problem in your custom code/problem arises because of the custom code.
The author is not responsible for any kind of system/data problem appears because of usages of this code.Reader/implementer
must do it on his/her own risk/responsibility.
Oracle Corporation may change API definition/usages. User must read the necessary documentation before using Oracle provided
APIs.

h) How to Send Reminder Notification to Approver


Oracle Workflow provide us several standrad functions which helps us to implement our business requirement.
Here we will discuss about two such standard functions to implement our requirement.
Basic Requirement

Our old requirement looks like "when a person applies for a leave it should go his/her supervisor for approval.Approver must be able to
provide his/her approval/rejection comments. The comments must be entered by the approver while rejecting the leave requisition.If he/she
rejects the leave requisition without entering comments, then it should raise an application error.If he/she approves the requisition it should be
optional.Approver must also be able to select theOrganization Leave Type from a list of values . If the leave gets rejected, dont store any
information in database.The approver should able to view/edit the person "Special Information Types" before approving the leave
request.Before approving the sick leave request the approver must able to see the submitted medical document."

Apart from the above requirement, We will introduce an additional requirement that "A reminder notification(email) must go to approver in
every 2 days untill he/she takes action (Approve or Reject) on the leave notification."

Solution Approach
First we will design discuss about the seeded function that we are going to use.

1) Compare Text
This function is use to compare the value of two Activity attribute.
Test Value:- A value which will be compared with the referenced value.This can be a constant value or can reference a item attribute.
Reference Value:- a text value which will be used as a reference value to compare.This can also be a constant value or can reference a item

attribute.

The comparison activities use the Comparison lookup type (Internal Name:- WFSTD_COMPARISON) for a result code. Possible values are
"Greater Than," "Less Than," "Equal," or "Null,". You can guide your workflow process based on how the value of an item type attribute
compares to a given value that one set.
1) Wait
This function pauses the process for the time that we specified in the activity attribute during the design of the workflow.The wiat functionality
can work for

a) A specific date
b) A given day of Month
c) A given day of the week
d) Relative time( A period of time after this activity is encountered).

Note:-1) When the process hit the Wait function, it goes to Deferred status. We must run background engine for
deferred activities to determine when the wait time has passed. The background engine then completes the Wait activity so that the
process can continue.

1) All the standard functions are available under itemtype Standard(Internal Name WFSTD).

Now Lets design/enhance the existing workflow model for the same.

1) Create a item attribute of type Text


Internal Name:- REMINDER_NOTIF_VAL_ATTR
Display Name:- Reminder Notification Attribute Val
Type:- Text

This attribute will be set when approver acts on his/her notification. Intially the value of the attribute will remain Null. Thus untill
approver acts on his/her notification, it will remain null and follow the path as shown above in the flowchart,i.e, will send

notification.

2) Load the itme type "standard" (Internal Name:- WFSTD) workflow defintion in a separate workflow builder window.To copy the
standrad functions please follow the following sequence.
a) Copy(ctrl+C) the following lookup type Wait Mode (Internal Name:-WFSTD_WAIT_MODE) from the standard
workflow(WFSTD) and Paste(ctrl+v) it in our custom
workflow.
b) Follow the same steps for "Day of Month"(WFSTD_DAY_OF_MONTH), "Day of
Week"(WFSTD_DAY_OF_WEEK),"Comparison"(WFSTD_COMPARISON)

Copying of these lookup types is required as this lookup types are referenced by Wait and Comparison function.
3) Now in the similar way copy the Wait(Internal Name:-WAIT) and "Compare Text" (Internal Name:-COMPARETEXT) function.

4) Now drag and drop the copied function from navigator window to process window.

5) Now double click on the WAIT function in process window--> Go to "Node Attribute Tab"
Select the Node attribute 1) Wait Mode:- Select value as "Relative Time" from the drop down
2) Relative Time:- Enter the Value as 2 ( since as per business requirement business requirement, every
2 days we have to send the reminder).

6) Similarly Double click on COMPARETEXT function --> Go to Node Attribute


a) Select Node attribute "Test Value" --> The "Test Value" will determine whether approver acted on the notification or not, so
we need reference a item attribute which will be set when approver approves/Reject notification.
Select Type:- Item Attribute
Value:- Select the item attribute "Reminder Notification Attribute Val"(Internal Name:-REMINDER_NOTIF_VAL_ATTR)

b) Select Node Attribute "Reference Value":- This is the reference value, hence keep this static and enter "APPROVE_REJECT"
in the Value field.

7) Now Create a notification. The performer of the notification will be same as the performer of the leave notification.
Internal Name:- REMINDER_EMAIL_NOTIF

Display Name:- Reminder Notification


Remember:- This is just a reminder notification/email,hence it will be a FYI notification.Hence no Result type is required.

8) Now create a message with the subitable text and subject Line
Internal Name:- REMINDER_MSG
Display Name:- Reminder Message
Subject :- Reminder:- Leave Approval for Person &REQUESTER_EMP_NAME (&REQUESTER_EMP_NO) is pending with you.
Body:- Dear <b>&SUP_EMP_NAME</b>,<br></br>
The person &REQUESTER_EMP_NAME(&REQUESTER_EMP_NO) has submitted leave requisition. Request you please take
necessary action on the requisition.
<br></br>
Regards
HR Team

As we did earlier(Refer earlier workflow tutorial/s) copy the desired item attribute and make them as message attribute
(Highlighted in blue above).

9) Attach the message with the newly created notification.


10) Now join all the nodes in the process window as shown below

11) Validate and save your work in database.


Pl/SQL PART
12) we have created an item attribute of type Text which we need to set once approver acts on notification.
We will use the existing post notification function used in approval notification "Test Leave Notification"(Internal Name:XX_TEST_LEAVE_NOTIF).
[for details of Post Notification function see the previous tutorial]

Now Compile your code and test the functionality.

Reminder notification
Here is a sample reminder notification that we created with the help of our above said modifications

Note:- 1) Ensure that Workflow background process is scheduled and running.


2) Once approver approves/reject the leave request, the wait function will automatically gets completed.Workflow
will take care of that.See the screen
shot below.

3) The point 2 holds true only when after execution of approval it hits "End" function. If it doesn't hit "END", Then we
have to use combination of OR and AND function as shown below.
[Only flow diagram is given.Rest is kept unsolved for reader's interest...]

4) There are several ways to implement this requirement. We have discussed here about only one possible solution.If
you are planning to modify the existing workflow, sometime it may not be possible to add anything in the existing Post
Notification function. The attribute can be set by adding a custom function immediately after approval and/or rejection of
the notification.

References:-

1) https://metalink.oracle.com
2) Oracle Workflow Developer's Guide ( Release 12) B31433-04
3) Oracle. Workflow API Reference Release 2.6.3.5 Part No. B1216302

Disclaimer:- This is a knowledge sharing site. This topic talks about a custom solution. Oracle Corporation may not provide you a
support for any data corruption or any other problem in your custom code/problem arises because of the custom code.
The author is not responsible for any kind of system/data problem appears because of usages of this code.Reader/implementer
must do it on his/her own risk/responsibility.
Oracle Corporation may change API definition/usages. User must read the necessary documentation before using Oracle provided
APIs.

S-ar putea să vă placă și