Dynamic Approval Group – BPM Workspace

Approval Management..

With the evolve of business processes and compliance, companies are emphasising on documents and approvals. Many applications use Approval Management extension (AMX) for approvals. With Oracle BPM Approval Management extension, you can define approval rules based on your business processes and decisions, such as whether to route documents to approvers in series or parallel, whether approvals should be based on employee supervisory hierarchy, position hierarchy, job levels or approval groups. You would define approval tasks in Oracle JDeveloper’s Human task editor and approvals are managed in BPM Worklist applications or BPM Workspace applications. You have used BPM workspace in the book and would be using the same application for AMX too.

INTRODUCTION

Following are the key elements that are involved in understanding and setting up approval routing rules.

  • Approval Request task – Business processes needs human intervention such as you have used in Sales -to-Contract process in this book. Document approval request task lets you send approval requests to approvers enabling them to make decisions and thus advancing the process.
  • Task Configuration – You need to configure event driven and data driven configuration for the document approval task before submitting documents for approval.
  • Stages – Stage lets you organize your approval routing rules into logical groupings and each stage is associated with a collection. A collection contains a set of attributes at a specific purchasing document level, such as header, lines etc which can be used to author routing rules.
  • Participant – You can add or edit task participant inside stages. Participants are assigned based on routing patters like – single, parallel, serial and FYI
  • Rule – Approval rule within a participant are composed of – rule name, condition, list builder and it’s attributes, response type and auto action.

An approval rule within a participant is composed of rule name, condition, list builder, list builder attributes, response type and auto actions. Rule name will identify the approval rule. Condition would indicate when the approval rule will be applied. A condition is defined based on the attributes seeded in  a collection.  Once the condition is satisfied, list builder would identify the type of users needed to approve or receive notification. There are many list builders supported like – Approval Group , Job level, position, supervisory and resource. Each list builder have set of properties that define it. Response type indicates if the participant are required to approve the task. If not they are FYI participants. Auto action  specifies if the list builder will automatically act on tasks. The auto action value specifies the outcome to be set such as – Approve or Reject.

Say you business requirement is to generate approvers list dynamically. They have basic business fulfilment to be taken care based on Industry type and then as per business defined logics, list of approvers would be generated. Business needs to incorporate the following logic to derive approvers dynamically:

To generate list dynamically, process need to interact with enterprise database. Enterprise database would have a procedure defined to take care of the logic and to return approvers list.

To fulfil the requirement, you have to follow the following steps :

  • Modify Approval task –  you would modify business analyst review task to build list using business rule.
  • Implementing Dynamic approval mechanism

Ensure that following user are created in security realm in Oracle SOA or are available in your identity management solution :Salesbusinessanalyst1,Salesbusinessanalyst2,ITbusinessanalyst1,ITbusinessanalyst2,businessanalyst and businessanalystmanager.

Modifying Approval Task

Task have task metadata and assignment section of task have stages defined. There can be many participants in a stage. You can set properties on the participant to determine the routing(serial or parallel) of the task. There are two kind of participants – value based and rule based.

You have created rule based participant in Chapter 5 – Defining Assignments – Sequential Stage and Serial Participant. Rule based participants are also called Rule sets and approval routing rules are authored inside a rule set. It’s the rule sets which you would view in Oracle BPM workspace and BPM Worklist applications.

You will modify the BusinessAnalystReview task so that it would be based on Business Rules.

  • Open JDeveloper in Default role
  • Go to project SalesToContact –> BusinessAnalystReview.task in Project Hierarchy
  • In the Task metadata, click on assignments section
  • Double click the participant block
  • Follow below details to create a List Builder based on Rule

Enter name of list rule set as ‘DynamicApprovalGroup’

This would create Decision Service components and a rule set in it.

  • Following is the Decision Service component. Click on Create Rule
  • Create a Rule with name  “DynamicApprovalGroupRule” and invoke the “CreateApprovalGroupList” API with following parameters :-
  • Name of the Group        : DynamicAG This is the name of the dynamic approval group which you have created in BPM Workspace
  • allowEnptyApprovalGroup  : true
  • responseType             :ResponseType.REQUIRED

As it’s a Approvers list and not a FYI list, we would use the ResponseType required.

  • rule Name: Enter the Rule name – DynamicApprovalGroupRule
  • lists : Lists
  • Deploy the process as per Chapter 3 – Deploy BPM projects

How it works.. When the process token reaches the approvals, it would be routed to the stages defined in task metadata and inside stage there are participants. You have defined participant as rule based and hence approval rule gets executed. Rule name will identify the rule and when condition gets satisfied, rule gets executed. Rule will build the participant based on list builder – Approval Group.

Approval group will be defined in the Oracle BPM workspace and it would invoke a Java class which in turns calls the PL/SQL procedure to dynamically build the list of participant. These participants will be returned to the rule and task gets assigned to these participant and based on response type it’s decided if participant will act on the task or it’s a FYI participant.

Verify Configured task..

To verify configured task you have to login to Oracle BPM workspace application with admin role. You can even change task configuration from here.

  • Login to Oracle BPM workspace @http://localhost:8001/bpm/workspace
  • Click on Administration Areas –>Task Administration –> Task Configuration
  • Configured Task section , click BusinessAnalystReview(1.0)

This is the task which you have modified to include the business rule for dynamic approval. Task is here as a  part of process being deployed which have BusinessAnalystReview.task

  • Click on ‘Data Driven’ tab and select the rule set – DynamicApprovalGroup
  • Expand the DynamicApprovalGroupRule which got listed when you have selected the rule set.

Implementing Dynamic approval mechanism

To implement dynamic approval mechanism, you would follow steps –

  • Create a PL/SQL procedure in DEV_SOAINFRA schema of the enterprise database. This schema comes as a part of SOA installation. However any business specified custom schema can be used for a similar operation.
  • Create a Java Class which accepts Task as parameters and invokes this PL/SQL procedure by passing argument and receiving approvers list.

You will create a PL/SQL procedure in enterprise database and a java class in JDeveloper or any other java editor. You have to place the java class at a globally know location specifying in SOA class path. Then you can create a Approval group and in this case you will create a dynamic approval group.

1. Create a PL/SQL procedure(named GetApprovers) in SOAINFRA schema which accepts Industry as argument and returns Approvers list

CREATE OR REPLACE

PROCEDURE GetApprovers(

    INDUSTRY IN VARCHAR2,

    APPROVERS OUT VARCHAR2 ) AUTHID CURRENT_USER

AS

BEGIN

  IF INDUSTRY LIKE ‘SALES’ THEN

    APPROVERS := ‘Salesbusinessanalyst1,Salesbusinessanalyst2’;

  END IF;

  IF INDUSTRY LIKE ‘IT’ THEN

    APPROVERS := ‘ITbusinessanalyst1,ITbusinessanalyst2’;

  ELSE

    APPROVERS := ‘businessanalyst,businessanalystmanager’;

  END IF;

END GetApprovers;

COMMIT;

2. Create a java class

Create a Java Class(named XXDynamicAG) which accepts Task as parameters and invokes this PL/SQL procedure – GetApprovers by passing ‘Industry’ as argument and receiving Approvers list.

  • Develop a custom dynamic approval group class
  • Place the class file at a globally know directory which is path of SOA class path.

For custom classes and jar ,oracle offers oracle.soa.ext_11.1.1 dir to place custom components like classes and jar files. Place your custom class @ $BEAHOME/Oracle_SOA/soa/modules/oracle.soa.ext_11.1.1/classes/XXDynamicAG.class

You would define an implementation class using the interface file IDynamicApprovalGroup.java defined in the package oracle.bpel.services.workflow.task. which contains only one public method that gets the approval group members and task object is the only input parameter.

public class XXDynamicAG implements IDynamicApprovalGroup {

public XXDynamicAG()   super() }

public List getMembers(Task task) {

Element payloadElem = task.getPayloadAsElement();

String IndustryName = null;

IndustryName = getElementValue(payloadElem, “Industry”);

Register the Dynamic approval group using the BPM workspace applications

Create a Dynamic Approval Group in BPM Workspace with name – DynamicAG based on the Java Class – XXDynamicAG

  • Login to Oracle BPM workspace with Administration account -weblogic
  • Click on Administration
  • Click on Administration Areas –>Task Administration –> Approval Groups
  • Create a Dynamic Group by clicking the Create Dynamic options and entering a name of the group as – DynamicApprovalGroup
    • Click Apply

Testing the Process..

  • Go to Oracle BPM Workspace
  • Login as salesrepresentative user to initiate the quote
  • Enter industry as ‘IT’ and enter other quote details
  • Submit the quote.
  • Login as ‘ITbusinessanalyst1’ user and you can verify that the task is assigned to it.

When the process token reaches the BusinessAnalystReview approval task, list of approvers is build through a call to dynamic approval group which would invoke a Java class which in turns calls the PL/SQL procedure to dynamically build the list of participant. These participants will be returned to the rule and task gets assigned to these participant. As the Industry type entered in quote was ‘IT’, PL/SQL would return ITbusinessanalyst1 and ITbusinessanalyst2 users and you can verify the task assignment to these users from Oracle BPM workspace.

You can use Oracle BPM Worklist application to perform similar operations you have performed using Oracle BPM workspace applications.

Write me on continuumtransfunctioner81@gmail.com for codes.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s