Sunday, 5 May 2013

Executing custom logic in BPM human task

Scenario: Excuting a custom logic in BPM human task before calling the action of BPM services. 
Let us think that we want some custom logic to be executed on click of Approve/Reject button in BPM human task. 

Solution:
To achieve this, we need to follow the below two steps,

Step 1: Write a managed bean and a submit method and write your custom code first and then the below code to invoke the BPM services.

public String submit(){
       // Custom Logic goes here.............................

        //Invoking BPM Services
                    Map map =
                        FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
                    oracle.bpel.services.workflow.worklist.adf.InvokeActionBean invokeActionBean =
                        (oracle.bpel.services.workflow.worklist.adf.InvokeActionBean)map.get("invokeActionBean");

                    String result = invokeActionBean.invokeOperation();
                     return result;
    }


Step 2: Configure this method as action method in the jspx for the Approve/Reject/Ok button.

                                               text="#{wf:getResourceValue('OK', 'bindings.customActions')}"
                                               disabled="#{!bindings.OK.enabled}"
                                               action="#{pageFlowScope.managedBean.submit}"
                                               partialSubmit="false"
                                               visible="#{wf:isCustomActionAvailable('OK', 'bindings.customActions')}"
                                               id="ctb1">
                       
                                     value="bindings.OK"/>
                     


2 comments:

  1. Hi Kamal,

    This is exactly what I was looking for. Quick question, which packages / libraries are you importing to make this work? I'm having trouble finding the right "Map" class.

    Thanks!

    Dave

    ReplyDelete
    Replies
    1. Hi Dave,
      Very sorry for replying very late, i hope you resolve your issue by now. This uses the basic FacesContext, please find the classes that are imported below,
      import java.util.Map;
      import javax.faces.context.FacesContext;
      import oracle.adf.model.BindingContext;
      import oracle.binding.BindingContainer;

      Delete