voting functionality of workflow

13
Voting Functionality in Oracle Workflow Author: Amit Jain Declaration I hereby declare that this document is based on my personal experiences. To the best of my knowledge, this document does not contain any material that infringes the copyrights of any other individual or organization. Target Readers Oracle Workflow PL/SQL Keywords Voting Ad hoc Roles Voting Methods Oracle Workflow Page 1 of 13

Upload: amit-jain

Post on 18-Apr-2015

187 views

Category:

Documents


8 download

DESCRIPTION

In the article , I have demonstrated the Voting functionality using a simple example which is one of the powerful features enshrined into Oracle Workflow

TRANSCRIPT

Page 1: Voting Functionality of Workflow

Voting Functionality in Oracle Workflow

Author: Amit Jain

Declaration

I hereby declare that this document is based on my personal experiences. To the best of my knowledge, this document does not contain any material that infringes the copyrights of any other individual or organization.

Target ReadersOracle WorkflowPL/SQL

KeywordsVoting Ad hoc RolesVoting MethodsOracle Workflow

Page 1 of 10

Page 2: Voting Functionality of Workflow

Introduction

In the article below, I have demonstrated the Voting functionality using a simple example which is one of the powerful features enshrined into Oracle Workflow. We have very commonly leveraged Workflows to deal with the levels deep Vertical Approval hierarchies for Purchase Orders, Requisitions, Sales Orders, Move Orders, Time booking so on so forth. But, at times we run into the few complex business scenarios where there are multiple decision makers who concertedly take a call for approval. Generally this scenario is more pertinent in the business for the Capital purchases where the decision making spreads around multiple hands.

Voting feature can be used to map the following and similar requirements of the business:

A) Eg. There are 7 Decision makers in a Purchasing Committee who have to send their consent for a Capital Purchase for the Organization. We need every one to mandatorily post their responses by Approving / Rejecting the Notification. The workflow should Approve or Reject the Purchase Order based on the Percentage scores of Approvals and Rejections. We can preset this % value to, may be, 51%. If more that 51% people agree to Purchase then the Workflow should proceed towards the Approval Transition else Rejection Transition.

B) In the second scenario there may be a little twist in the business need. We don't want to wait for everyone to send their Approvals for the Purchase. But need just 50% approval consent from the committee members. As the 50% people approve the Purchase, the PO moves forth to Approval transition without even waiting the response from the rest of the members in the committee.

The above said 2 scenarios may snowball further to any complexity levels depending on the business needs. Workflow meticulously maps the complex scenarios using WF_STANDARD.voteforresulttype seeded API. There are primarily 3 types of Voting methods which are mapped in the seeded APIA) REQUIRE_ALL_VOTESB) WAIT_FOR_ALL_VOTESC) TALLY_ON_EVERY_VOTE

On top of it Oracle also extends the flexibility of writing our own Custom package to maps even more complex scenarios. The pre-condition to writing the Custom package is that the signature of the Procedure should exactly match to one of WF_STANDARD.voteforresulttype

Case demonstratedI am using a very simple example to demonstrate the aforesaid functionality. We will send a Voting notification to 3 members who in turn can respond back with Yes and No answers on the Notification. If more that 50% (translates down to 2 out of 3) say Yes then a notification will be sent to another member confirming that the decision of the

Page 2 of 10

Page 3: Voting Functionality of Workflow

committee is Yes else a notification will be sent to another member confirming that the decision of the committee is No. Snapshot of the workflow is as below

SolutionWe will first create a Ad hoc Role in the system whose members can be changes dynamically. But, here in the case I am creating the Ad hoc roles and add the users in a static manner using the scripts below./***Adhoc role created and by default "00812780" user added to the Role*****/.DECLARE lv_role varchar2(100) := 'Voting Role'; lv_role_desc varchar2(100) := 'Voting Role'; BEGIN wf_directory.CreateAdHocRole(lv_role, lv_role_desc, NULL, NULL, 'Voting Role', 'MAILHTML', '00812780', NULL, NULL, 'ACTIVE', NULL); End; /

/***Adding 2 more members to the Adhoc Role******/BEGIN WF_DIRECTORY.AddUsersToAdHocRole('Voting Role', '00825505');WF_DIRECTORY.AddUsersToAdHocRole('Voting Role', '00399360');END; /

Defining Message

A) Voting Message

Page 3 of 10

Page 4: Voting Functionality of Workflow

B) Message of Disagreement (False Message)

C) Message of Agreement (True Message)

Define Notifications & Notification Attribute

A) VOTING NOTIFICATION as depicted belowFunction Name: WF_STANDARD.VOTEFORRESULTTYPEResult Type: Boolean (We are using a seeded Lookup Type. However, we can define a custom Lookup Type as well depending on the business need)

Page 4 of 10

Page 5: Voting Functionality of Workflow

Message: Cast your Vote- Testing (Defined in a step prior)

Expand Roles: Yes (Check Expand Roles so that the Workflow Engine polls for responses from the multiple users in the role rather than just from the first user in the role that replies)

Add 3 Attributes to the Notification Activity.a) Notification Attribute 1 Internal Name : VOTING_OPTION (Mandatorily the name should be same if we are using seeded API WF_STANDARD.VOTEFORRESULTTYPE)

Value : WAIT_FOR_ALL_VOTES (Mandatorily the name should be same if we are using seeded API WF_STANDARD.VOTEFORRESULTTYPE. The other possible values are REQUIRE_ALL_VOTES,TALLY_ON_EVERY_VOTE)

b) Notification Attribute 2If we use the WF_STANDARD.VOTEFORRESULTTYPE tallying function, create a custom activity attribute of type Number for each possible voting response. Remember that each possible voting response is a lookup code associated with the voting activity's result type. Hence, when you define your custom activity attribute, the internal name of the activity attribute must match the internal name of the lookup code , that is, the response value. The value of the activity attribute can either be blank or a number that represents the percentage of votes required for a particular result. If you provide a percentage, then the result is matched if the actual tallied percentage for that

Page 5 of 10

Page 6: Voting Functionality of Workflow

response is greater than your specified percentage. If you leave an activity attribute value blank, then the Workflow Engine treats the response for that activity attribute as a default. In other words, if no particular percentage is satisfied after the votes are tallied, then the response that received the highest number of votes among those associated with a blank activity attribute becomes the result.

Note: If the tallied votes do not satisfy any response percentages and there are no default responses (blank activity attributes) specified, the result is #NOMATCH. If a <No Match> transition from the voting activity exists, then the Workflow Engine takes this transition, otherwise, it takes the <Default> transition. If no <Default> transition exists, it raises an error that no transition for the result is available (ERROR:#NOTRANSITION).

Note: If the tallied votes satisfy more than one response percentage or if no response percentage is satisfied, but a tie occurs among the default responses, the result is #TIE. If a <Tie> transition from the voting activity exists, then the Workflow Engine takes this transition, otherwise, it takes the <Default> transition. If no <Default> transition exists, it raises an error that no transition for the result is available (ERROR:#NOTRANSITION).

The Internal Name of the Attribute should be T to mirror the Lookup Code of Lookup Type Boolean.Value should be

Internal Name : TType: NumberValue: 50 (Indicates that at least 50% should agree to float the IPO)

c) Notification Attribute 3 Internal Name : FType: NumberValue: 50 (Indicates that at least 50% should agree to float the IPO)

Page 6 of 10

Page 7: Voting Functionality of Workflow

B) This notification will attach the Agreement message

C) This notification will attach the Dis-Agreement message

Loading the RolesGo to File Load Roles from Database

a) Select "Voting Role" (Committee members Ad hoc role created in the preceding steps)

Page 7 of 10

Page 8: Voting Functionality of Workflow

b) 00812780 (Person who will get the notification the Directors agreed/ disagreed to floating IPO decision)

Item AttributeThe Item Attribute below will contain the value of the Ad Hoc role Voting Role

Process ActivitySet the Performer role for the Notification Activities as indicated below:

Set the Performer of the Voting Notification to Voting Role Item Attribute.

Page 8 of 10

Page 9: Voting Functionality of Workflow

00812780 will be the person who will receive the notification of the outcome from Voting Notification activity.

Testing the FunctionalityWe will fire 2 instances of the workflow to test True and False scenariosA) 2 out of 3 people responded as True and one as False

BeginWF_ENGINE.CREATEPROCESS('VOT_TYP1', '004', 'VOT_PROCESS1'); WF_ENGINE.STARTPROCESS('VOT_TYP1', '004'); commit;end;/Attaching herewith the Results from my Test Environment from the Workflow Status Monitor View

Page 9 of 10

Page 10: Voting Functionality of Workflow

B) 2 out of 3 people responded as False and one as True

BeginWF_ENGINE.CREATEPROCESS('VOT_TYP1', '005', 'VOT_PROCESS1'); WF_ENGINE.STARTPROCESS('VOT_TYP1', '005'); commit;end;/

Attaching herewith the Results from my Test Environment from the Workflow Status Monitor View

Attaching herewith the Workflow File used for the example above

References:Workflow User Guide http://docs.oracle.com/cd/B14099_19/integrate.1012/b12161/defcom59.htm

Page 10 of 10