Documente Academic
Documente Profesional
Documente Cultură
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.
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.
References:-additional 1) https://metalink.oracle.com
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 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.
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)
2)
Leave Type
3)
4)
Leave to date
Requestor person id
2)
3)
4)
Leave Type
5)
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
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)
(Type-Text)
3)
(Type-Text)
4)
Leave Type
(Type-Text)
5)
(Type-Date)
6)
Leave to date
(Type-Date)
7)
Supervisor person id
(Type-Number)
8)
(Type-Text)
9)
(Type-Text)
Notification
A single notification to send information to supervisor of requestor
Message
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.
To design our discussed custom workflow, we need to create following workflow components
Item Attribute
1)
Requestor person id
(Type-Number)
9)
2)
(Type-Text)
3)
(Type-Text)
4)
Leave Type
(Type-Text)
5)
(Type-Date)
6)
Leave to date
(Type-Date)
7)
Supervisor person id
(Type-Number)
8)
(Type-Text)
(Type-Text)
Lookup Type/Code
Lookup code a) Approve b) Reject
Lookup Type:- APPROVE_REJ
Function Activity
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
.
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
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.
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.
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
** => 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.
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.
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
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.
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."
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"
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
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).
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."
Design Appraoch
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.
4) Our procedure is ready to attach with the workflow. Open the approver notification and attach the procedure in "Function Name"
field.
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'.
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
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
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".
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
:- 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
plsqlclob:<package>.<procedure_name>/XXXXX
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
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
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.
IN
BOOLEAN,
PLS_INTEGER := 10);
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_lob
IN
BLOB,
amount
IN
INTEGER,
dest_offset IN
INTEGER := 1,
src_offset IN
INTEGER := 1);
dest_lob
src_lob
amount
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
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
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.
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
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.
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.
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.
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.
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.
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).
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
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).
Reminder notification
Here is a sample reminder notification that we created with the help of our above said modifications
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.